diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/AnyExpectationSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/AnyExpectationSamples.kt index e62ada933d..d0f6b72d79 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/AnyExpectationSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/AnyExpectationSamples.kt @@ -107,6 +107,9 @@ class AnyExpectationSamples { } fails { // because sub-expectation fails + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(1).notToEqualNull { toBeLessThan(0) // fails toBeGreaterThan(5) // still evaluated even though `toBeLessThan` already fails, @@ -152,6 +155,9 @@ class AnyExpectationSamples { } fails { // because sub-expectation fails + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(n).toBeAnInstanceOf { toEqual(-1L) // fails toBeLessThan(2L) // still evaluated even though `toEqual` already fails, @@ -223,14 +229,13 @@ class AnyExpectationSamples { } fails { - expect(13).toBeAnInstanceOf().and { - // introduces an expectation-group block where all expectations inside - // are evaluated together; for more details see: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - // use `.and.` if you want fail fast behaviour + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(13).toBeAnInstanceOf().and { notToEqualOneOf(1, 2, 13) // fails toBeLessThan(10) // still evaluated and included in the error report + // use `.and.` if you want fail fast behaviour } } } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ArraySubjectChangerSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ArraySubjectChangerSamples.kt index 6972344ac7..16bba860af 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ArraySubjectChangerSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ArraySubjectChangerSamples.kt @@ -23,21 +23,19 @@ class ArraySubjectChangerSamples { @Test fun asList() { - expect(arrayOf("A", "B")) - .asList { // subject within this expectation-group is of type List - toEqual(listOf("A", "B")) - } // subject here is back to type Array + expect(arrayOf("A", "B")).asList { // subject within this expectation-group is of type List + toEqual(listOf("A", "B")) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(arrayOf("A", "B")) - .asList { - toContain("C") // fails - toContain("D") // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(arrayOf("A", "B")).asList { + toContain("C") // fails + toContain("D") // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -52,12 +50,11 @@ class ArraySubjectChangerSamples { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect>(arrayOf("A", "B")) - .asList { - toContain("C") // fails - toContain("D") // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect>(arrayOf("A", "B")).asList { + toContain("C") // fails + toContain("D") // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -70,21 +67,19 @@ class ArraySubjectChangerSamples { @Test fun byteArrAsList() { - expect(byteArrayOf(1, 2, 3)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1, 2, 3)) - } // subject here is back to type Array + expect(byteArrayOf(1, 2, 3)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1, 2, 3)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(byteArrayOf(1, 2, 3)) - .asList { - toContain(98) // fails - toContain(99) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(byteArrayOf(1, 2, 3)).asList { + toContain(98) // fails + toContain(99) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -97,21 +92,19 @@ class ArraySubjectChangerSamples { @Test fun charArrAsList() { - expect(charArrayOf('A', 'B', 'C')) - .asList { // subject within this expectation-group is of type List - toEqual(listOf('A', 'B', 'C')) - } // subject here is back to type Array + expect(charArrayOf('A', 'B', 'C')).asList { // subject within this expectation-group is of type List + toEqual(listOf('A', 'B', 'C')) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(charArrayOf('A', 'B', 'C')) - .asList { - toContain('X') // fails - toContain('Y') // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(charArrayOf('A', 'B', 'C')).asList { + toContain('X') // fails + toContain('Y') // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -124,21 +117,19 @@ class ArraySubjectChangerSamples { @Test fun shortArrAsList() { - expect(shortArrayOf(1, 2, 3)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1, 2, 3)) - } // subject here is back to type Array + expect(shortArrayOf(1, 2, 3)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1, 2, 3)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(shortArrayOf(1, 2, 3)) - .asList { - toContain(98) // fails - toContain(99) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(shortArrayOf(1, 2, 3)).asList { + toContain(98) // fails + toContain(99) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -151,21 +142,19 @@ class ArraySubjectChangerSamples { @Test fun intArrAsList() { - expect(intArrayOf(1, 2, 3)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1, 2, 3)) - } // subject here is back to type Array + expect(intArrayOf(1, 2, 3)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1, 2, 3)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(intArrayOf(1, 2, 3)) - .asList { - toContain(98) // fails - toContain(99) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(intArrayOf(1, 2, 3)).asList { + toContain(98) // fails + toContain(99) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -178,21 +167,19 @@ class ArraySubjectChangerSamples { @Test fun longArrAsList() { - expect(longArrayOf(1L, 2L, 3L)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1L, 2L, 3L)) - } // subject here is back to type Array + expect(longArrayOf(1L, 2L, 3L)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1L, 2L, 3L)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(longArrayOf(1L, 2L, 3L)) - .asList { - toContain(98L) // fails - toContain(99L) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(longArrayOf(1L, 2L, 3L)).asList { + toContain(98L) // fails + toContain(99L) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -205,21 +192,19 @@ class ArraySubjectChangerSamples { @Test fun floatArrAsList() { - expect(floatArrayOf(1f, 2f, 3f)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1f, 2f, 3f)) - } // subject here is back to type Array + expect(floatArrayOf(1f, 2f, 3f)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1f, 2f, 3f)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(floatArrayOf(1f, 2f, 3f)) - .asList { - toContain(98f) // fails - toContain(99f) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(floatArrayOf(1f, 2f, 3f)).asList { + toContain(98f) // fails + toContain(99f) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -232,21 +217,19 @@ class ArraySubjectChangerSamples { @Test fun doubleArrAsList() { - expect(doubleArrayOf(1.1, 2.2, 3.3)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(1.1, 2.2, 3.3)) - } // subject here is back to type Array + expect(doubleArrayOf(1.1, 2.2, 3.3)).asList { // subject within this expectation-group is of type List + toEqual(listOf(1.1, 2.2, 3.3)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(doubleArrayOf(1.1, 2.2, 3.3)) - .asList { - toContain(98.1) // fails - toContain(99.2) // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - } + expect(doubleArrayOf(1.1, 2.2, 3.3)).asList { + toContain(98.1) // fails + toContain(99.2) // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + } } } @@ -259,24 +242,22 @@ class ArraySubjectChangerSamples { @Test fun booleanArrAsList() { - expect(booleanArrayOf(true, false)) - .asList { // subject within this expectation-group is of type List - toEqual(listOf(true, false)) - } // subject here is back to type Array + expect(booleanArrayOf(true, false)).asList { // subject within this expectation-group is of type List + toEqual(listOf(true, false)) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(booleanArrayOf(true, true)) - .asList { - // fails - toContain(false) + expect(booleanArrayOf(true, true)).asList { + // fails + toContain(false) - // still evaluated even though above `toContain` already fails - // use `.asList().` if you want a fail fast behaviour - toContain.inAnyOrder.atLeast(3).value(true) - } + // still evaluated even though above `toContain` already fails + // use `.asList().` if you want a fail fast behaviour + toContain.inAnyOrder.atLeast(3).value(true) + } } } } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/FeatureExtractorSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/FeatureExtractorSamples.kt index 5818308f22..7c25a6570b 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/FeatureExtractorSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/FeatureExtractorSamples.kt @@ -34,22 +34,19 @@ class FeatureExtractorSamples { fun its() { val person = Person(name = "John Smith", age = 25) - expect(person) - .its({ age }) { // subject within this expectation-group is of type Int - toBeGreaterThan(18) - toBeLessThan(35) - } // subject here is back to type Person + expect(person).its({ age }) { // subject within this expectation-group is of type Int + toBeGreaterThan(18) + toBeLessThan(35) + } // subject here is back to type Person fails { - expect(person) - .its({ age }) { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - toBeGreaterThan(40) // fails - toBeLessThan(50) // still evaluated, use `.its.` if you want fail fast behaviour - } + expect(person).its({ age }) { + toBeGreaterThan(40) // fails + toBeLessThan(50) // still evaluated, use `.its.` if you want fail fast behaviour + } } } @@ -82,15 +79,13 @@ class FeatureExtractorSamples { } // subject here is back to type Person fails { - expect(person) - .feature(Person::name) { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated, use `.feature(kprop).` if you want fail fast behaviour - } + expect(person).feature(Person::name) { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated, use `.feature(kprop).` if you want fail fast behaviour + } } } @@ -121,22 +116,19 @@ class FeatureExtractorSamples { fun f(person: Person) = person.name - expect(person) - .feature(::f) { // subject is now String, after function [f] is applied - toStartWith("John") - toEndWith("Smith") - } // subject here is back type Person + expect(person).feature(::f) { // subject is now String, after function [f] is applied + toStartWith("John") + toEndWith("Smith") + } // subject here is back type Person fails { - expect(person) - .feature(::f) { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated, use `.feature(kfun).` if you want fail fast behaviour - } + expect(person).feature(::f) { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated, use `.feature(kfun).` if you want fail fast behaviour + } } } @@ -169,26 +161,23 @@ class FeatureExtractorSamples { fun f(person: Person, title: String) = "$title ${person.name}" - expect(person) - .feature( - ::f, - "Dr." - ) {// subject within this expectation-group is of type String (actually the return value of calling `f` with the given argument) - toStartWith("Dr. John") - toEndWith("Smith") - } // subject here is back type Person + expect(person).feature( + ::f, + "Dr." + ) {// subject within this expectation-group is of type String (actually the return value of calling `f` with the given argument) + toStartWith("Dr. John") + toEndWith("Smith") + } // subject here is back type Person fails { - expect(person) - .feature(::f, "Dr.") { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated even though `toStartWith` already fails - // use `.feature(kfun, arg1).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.") { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated even though `toStartWith` already fails + // use `.feature(kfun, arg1).` if you want fail fast behaviour + } } } @@ -233,16 +222,14 @@ class FeatureExtractorSamples { } // subject here is back type Person fails { - expect(person) - .feature(::f, "Dr.", "PMP") { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated even though `toStartWith` already fails - // use `.feature(kfun, arg1, arg2).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.", "PMP") { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated even though `toStartWith` already fails + // use `.feature(kfun, arg1, arg2).` if you want fail fast behaviour + } } } @@ -293,16 +280,14 @@ class FeatureExtractorSamples { } // subject here is back type Person fails { - expect(person) - .feature(::f, "Dr.", "PMP", "Native") { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated even though `toStartWith` already fails - // use `.feature(kfun, a1, a2, a3).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.", "PMP", "Native") { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated even though `toStartWith` already fails + // use `.feature(kfun, a1, a2, a3).` if you want fail fast behaviour + } } } @@ -327,8 +312,10 @@ class FeatureExtractorSamples { .toEndWith("German level: C1") fails { - expect(person) - .feature(::f, "Dr.", "PMP", "Native", "C1") + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.", "PMP", "Native", "C1") .toStartWith("Kevin") // fails .toEndWith("Bacon") // not evaluated/reported because `toStartWith` already fails // use `.feature(kfun, a1, a2, a3, a4) { ... }` if you want that all assertions are evaluated @@ -357,16 +344,14 @@ class FeatureExtractorSamples { } // subject here is back type Person fails { - expect(person) - .feature(::f, "Dr.", "PMP", "Native", "C1") { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated even though `toStartWith` already fails - // use `.feature(kfun, a1, a2, a3, a4).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.", "PMP", "Native", "C1") { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated even though `toStartWith` already fails + // use `.feature(kfun, a1, a2, a3, a4).` if you want fail fast behaviour + } } } @@ -425,16 +410,14 @@ class FeatureExtractorSamples { } // subject here is back type Person fails { - expect(person) - .feature(::f, "Dr.", "PMP", "Native", "C1", "B2") { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toStartWith("Kevin") // fails - toEndWith("Bacon") // still evaluated even though `toStartWith` already fails - // use `.feature(kfun, a1, a2, a3, a4, a5).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature(::f, "Dr.", "PMP", "Native", "C1", "B2") { + toStartWith("Kevin") // fails + toEndWith("Bacon") // still evaluated even though `toStartWith` already fails + // use `.feature(kfun, a1, a2, a3, a4, a5).` if you want fail fast behaviour + } } } @@ -472,22 +455,20 @@ class FeatureExtractorSamples { } // subject here is back type Person fails { + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + // Reporting will include the description: // expected that subject: Person(name=John Smith, age=25) // * Actual age: 25 // - to be less than: 30 // - to be greater than: 30 - expect(person) - .feature("Actual age", Person::age) { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toBeLessThan(20) // fails - toBeGreaterThan(30) // still evaluated even though `toBeLessThan` already fails - // use `.feature(descr, kprop).` if you want fail fast behaviour - } + expect(person).feature("Actual age", Person::age) { + toBeLessThan(20) // fails + toBeGreaterThan(30) // still evaluated even though `toBeLessThan` already fails + // use `.feature(descr, kprop).` if you want fail fast behaviour + } } } @@ -520,16 +501,14 @@ class FeatureExtractorSamples { } // subject here is back to Person fails { - expect(person) - .feature({ f(it::age) }) { - // introduces an expectation-group block - // all expectations are evaluated inside an expectation-group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups - - toBeGreaterThan(30) // fails - toBeLessThan(20) // still evaluated even though `toBeLessThan` already fails - // use `.feature({ extractor }).` if you want fail fast behaviour - } + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(person).feature({ f(it::age) }) { + toBeGreaterThan(30) // fails + toBeLessThan(20) // still evaluated even though `toBeLessThan` already fails + // use `.feature({ extractor }).` if you want fail fast behaviour + } } } @@ -548,6 +527,7 @@ class FeatureExtractorSamples { } private val dataGenerator = DataGenerator() + @Test fun extractSubject() { val persons = dataGenerator.getRandomPersonsWithChildren() diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/Fun0ExpectationSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/Fun0ExpectationSamples.kt index 84bf132d64..a0ee1a315b 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/Fun0ExpectationSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/Fun0ExpectationSamples.kt @@ -61,14 +61,14 @@ class Fun0ExpectationSamples { } // subject keeps type String also after the block fails { // because an exception was thrown, but since we use an expectation-group... - expect<() -> String> { throw IllegalStateException("abc") } + expect { throw IllegalStateException("abc") } .notToThrow { toStartWith("abc") // ... reporting mentions that subject's message was expected `to start with: "abc"` } } fails { // because an exception was thrown, but since we use an expectation-group... - expect<() -> String> { throw IllegalStateException("abc") } + expect { throw IllegalStateException("abc") } .notToThrow { toStartWith("abc") // ... reporting mentions that subject's message was expected `to start with: "abc"` } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapEntryFeatureExtractorSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapEntryFeatureExtractorSamples.kt index b3dac92e25..60265ad8ad 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapEntryFeatureExtractorSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapEntryFeatureExtractorSamples.kt @@ -32,6 +32,9 @@ class MapEntryFeatureExtractorSamples { } // subject here is back to type Map.Entry fails { + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(entry).key { // subject inside this expectation-group is of type Int (actually 1) toEqual(2) // fails toBeLessThan(0) // still evaluated even though `toEqual` already fails, @@ -66,6 +69,9 @@ class MapEntryFeatureExtractorSamples { } // subject here is back to type Map.Entry fails { + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(entry).value { // subject inside this expectation-group is of type String (actually "a") toEqual("b") // fails toStartWith("z") // still evaluated even though `toEqual` already fails, diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapFeatureExtractorSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapFeatureExtractorSamples.kt index bc818695c6..8dfe0af57d 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapFeatureExtractorSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapFeatureExtractorSamples.kt @@ -34,25 +34,25 @@ class MapFeatureExtractorSamples { toEqual("a") } // subject here is back to type Map - fails { - expect(mapOf(1 to "a")) - .getExisting(1) { // subject inside this expectation-group is of type String (actually "a") - toEqual("b") // fails because "a" is not equal to "b" - toStartWith("z") // still evaluated because we use an expectation-group block - // use `.getExisting(key).` if you want a fail fast behaviour - } - } - - fails { + fails { //fails because key 2 does not exist but... // all expectations are evaluated inside an expectation-group block; for more details: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group expect(mapOf(1 to "a")) - .getExisting(2) { // fails because key 2 does not exist - toEqual("a") // still evaluated because we use an expectation-group block - // use `.getExisting(key).` if you want a fail fast behaviour + .getExisting(2) { + toEqual("a") //... still reported as we are inside an expectation-group block } } + + fails { + expect(mapOf(1 to "a")).getExisting(1) { // subject inside this expectation-group is of type String (actually "a") + toEqual("b") // fails because "a" is not equal to "b" + toStartWith("z") // still evaluated because we use an expectation-group block + // use `.getExisting(key).` if you want a fail fast behaviour + } + } + + } @Test @@ -72,21 +72,19 @@ class MapFeatureExtractorSamples { @Test fun keys() { - expect(mapOf(1 to "a")) - .keys { // subject inside this expectation-group is of type Set (containing 1) - toEqual(setOf(1)) - } // subject here is back to type Map + expect(mapOf(1 to "a")).keys { // subject inside this expectation-group is of type Set (containing 1) + toEqual(setOf(1)) + } // subject here is back to type Map fails { // all expectations are evaluated inside an expectation-group block; for more details: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(mapOf(1 to "a")) - .keys { // subject inside this expectation-group is of type Set (containing 1) - toEqual(setOf(2)) // fails because 1 is not equal to 2 - toHaveSize(3) // still evaluated because we use an expectation-group block - // use `.keys.` if you want a fail fast behaviour - } + expect(mapOf(1 to "a")).keys { // subject inside this expectation-group is of type Set (containing 1) + toEqual(setOf(2)) // fails because 1 is not equal to 2 + toHaveSize(3) // still evaluated because we use an expectation-group block + // use `.keys.` if you want a fail fast behaviour + } } } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapSubjectChangerSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapSubjectChangerSamples.kt index 73b8dd9428..6a9d55c475 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapSubjectChangerSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/MapSubjectChangerSamples.kt @@ -25,6 +25,9 @@ class MapSubjectChangerSamples { } // subject here is back to type Map fails { + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(mapOf(1 to "a")).asEntries { // subject inside this expectation-group is of type Map.Entry (actually <1,"a">) toEqual(mapOf(1 to "b").entries) // fails because <1,"a"> is not equal to <1,"b"> } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/PairFeatureExtractorSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/PairFeatureExtractorSamples.kt index d37b07da77..b1ba0e522c 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/PairFeatureExtractorSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/PairFeatureExtractorSamples.kt @@ -40,12 +40,11 @@ class PairFeatureExtractorSamples { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(pair) - .first { - toBeGreaterThan(2) // fails - toBeLessThan(0) // still evaluated even though `toBeGreaterThan` already fails - // use `.first.` if you want a fail fast behaviour - } + expect(pair).first { + toBeGreaterThan(2) // fails + toBeLessThan(0) // still evaluated even though `toBeGreaterThan` already fails + // use `.first.` if you want a fail fast behaviour + } } } @@ -83,12 +82,11 @@ class PairFeatureExtractorSamples { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(pair) - .second { - toBeGreaterThan(2) // fails - toBeLessThan(0) // still evaluated even though `toBeGreaterThan` already fails, - // use `.second.` if you want a fail fast behaviour - } + expect(pair).second { + toBeGreaterThan(2) // fails + toBeLessThan(0) // still evaluated even though `toBeGreaterThan` already fails, + // use `.second.` if you want a fail fast behaviour + } } } } diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ResultExpectationSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ResultExpectationSamples.kt index 519ba286f5..89fc020aee 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ResultExpectationSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ResultExpectationSamples.kt @@ -23,6 +23,9 @@ class ResultExpectationSamples { } fails { // because it was a Failure + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(Result.failure(ArithmeticException())) .toBeASuccess() // fails .toBeGreaterThan(12) // not evaluated/reported because `toBeASuccess` already fails @@ -47,6 +50,7 @@ class ResultExpectationSamples { } fails { // because it was a Failure, but since we use an expectation-group... + expect(Result.failure(ArithmeticException())).toBeASuccess { toBeGreaterThan(12) // ...reporting mentions that subject was expected `to be greater than: 12` // use `.toBeASuccess.` if you want a fail fast behaviour @@ -56,7 +60,6 @@ class ResultExpectationSamples { } - @Test fun toBeAFailureFeature() { val message = "wrong argument" diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/AnyExpectationSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/AnyExpectationSamples.kt index 8d347df5a9..e2bf1a96a9 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/AnyExpectationSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/AnyExpectationSamples.kt @@ -199,11 +199,10 @@ class AnyExpectationSamples { } fails { - expect(13).toBeAnInstanceOf() and { - // introduces an expectation-group block - // all expectations are evaluated inside an expectations group block; for more details: - // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(13).toBeAnInstanceOf() and { it notToEqualOneOf values(1, 2, 13) // fails it toBeLessThan 10 // still evaluated and included in the error report // use ` and o` if you want fail fast behaviour diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ArraySubjectChangerSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ArraySubjectChangerSamples.kt index d3fe5e0a6f..ae64d93ca2 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ArraySubjectChangerSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ArraySubjectChangerSamples.kt @@ -14,20 +14,19 @@ class ArraySubjectChangerSamples { @Test fun asList() { - expect(arrayOf("A", "B")) - .asList { // subject within this expectation-group is of type List - it toEqual listOf("A", "B") - } // subject here is back to type Array + expect(arrayOf("A", "B")).asList { // subject within this expectation-group is of type List + it toEqual listOf("A", "B") + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(arrayOf("A", "B")) - .asList { - it toContain "C" // fails - it toContain "D" // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(arrayOf("A", "B")).asList { + it toContain "C" // fails + it toContain "D" // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -41,12 +40,12 @@ class ArraySubjectChangerSamples { fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect>(arrayOf("A", "B")) - .asList { - it toContain "C" // fails - it toContain "D" // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect>(arrayOf("A", "B")).asList { + it toContain "C" // fails + it toContain "D" // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -66,12 +65,12 @@ class ArraySubjectChangerSamples { fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(byteArrayOf(1, 2, 3)) - .asList { - it toContain 98 // fails - it toContain 99 // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(byteArrayOf(1, 2, 3)).asList { + it toContain 98 // fails + it toContain 99 // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -83,20 +82,19 @@ class ArraySubjectChangerSamples { @Test fun charArrAsList() { - expect(charArrayOf('A', 'B', 'C')) - .asList { // subject within this expectation-group is of type List - it toEqual listOf('A', 'B', 'C') - } // subject here is back to type Array + expect(charArrayOf('A', 'B', 'C')).asList { // subject within this expectation-group is of type List + it toEqual listOf('A', 'B', 'C') + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(charArrayOf('A', 'B', 'C')) - .asList { - it toContain 'X' // fails - it toContain 'Y' // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(charArrayOf('A', 'B', 'C')).asList { + it toContain 'X' // fails + it toContain 'Y' // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -108,20 +106,19 @@ class ArraySubjectChangerSamples { @Test fun shortArrAsList() { - expect(shortArrayOf(1, 2, 3)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(1, 2, 3) - } // subject here is back to type Array + expect(shortArrayOf(1, 2, 3)).asList { // subject within this expectation-group is of type List + it toEqual listOf(1, 2, 3) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(shortArrayOf(1, 2, 3)) - .asList { - it toContain 98 // fails - it toContain 99 // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(shortArrayOf(1, 2, 3)).asList { + it toContain 98 // fails + it toContain 99 // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -133,20 +130,18 @@ class ArraySubjectChangerSamples { @Test fun intArrAsList() { - expect(intArrayOf(1, 2, 3)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(1, 2, 3) - } // subject here is back to type Array + expect(intArrayOf(1, 2, 3)).asList { // subject within this expectation-group is of type List + it toEqual listOf(1, 2, 3) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(intArrayOf(1, 2, 3)) - .asList { - it toContain 98 // fails - it toContain 99 // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + expect(intArrayOf(1, 2, 3)).asList { + it toContain 98 // fails + it toContain 99 // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -158,20 +153,18 @@ class ArraySubjectChangerSamples { @Test fun longArrAsList() { - expect(longArrayOf(1L, 2L, 3L)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(1L, 2L, 3L) - } // subject here is back to type Array + expect(longArrayOf(1L, 2L, 3L)).asList { // subject within this expectation-group is of type List + it toEqual listOf(1L, 2L, 3L) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(longArrayOf(1L, 2L, 3L)) - .asList { - it toContain 98L // fails - it toContain 99L // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + expect(longArrayOf(1L, 2L, 3L)).asList { + it toContain 98L // fails + it toContain 99L // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -183,20 +176,18 @@ class ArraySubjectChangerSamples { @Test fun floatArrAsList() { - expect(floatArrayOf(1f, 2f, 3f)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(1f, 2f, 3f) - } // subject here is back to type Array + expect(floatArrayOf(1f, 2f, 3f)).asList { // subject within this expectation-group is of type List + it toEqual listOf(1f, 2f, 3f) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(floatArrayOf(1f, 2f, 3f)) - .asList { - it toContain 98f // fails - it toContain 99f // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + expect(floatArrayOf(1f, 2f, 3f)).asList { + it toContain 98f // fails + it toContain 99f // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -208,20 +199,19 @@ class ArraySubjectChangerSamples { @Test fun doubleArrAsList() { - expect(doubleArrayOf(1.1, 2.2, 3.3)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(1.1, 2.2, 3.3) - } // subject here is back to type Array + expect(doubleArrayOf(1.1, 2.2, 3.3)).asList { // subject within this expectation-group is of type List + it toEqual listOf(1.1, 2.2, 3.3) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(doubleArrayOf(1.1, 2.2, 3.3)) - .asList { - it toContain 98.1 // fails - it toContain 99.2 // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(doubleArrayOf(1.1, 2.2, 3.3)).asList { + it toContain 98.1 // fails + it toContain 99.2 // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } @@ -233,20 +223,19 @@ class ArraySubjectChangerSamples { @Test fun booleanArrAsList() { - expect(booleanArrayOf(true, false)) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(true, false) - } // subject here is back to type Array + expect(booleanArrayOf(true, false)).asList { // subject within this expectation-group is of type List + it toEqual listOf(true, false) + } // subject here is back to type Array fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(booleanArrayOf(true, true)) - .asList { - it toContain false // fails - it toContain o inAny order atLeast 3 value true // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(booleanArrayOf(true, true)).asList { + it toContain false // fails + it toContain o inAny order atLeast 3 value true // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CollectionFeatureExtractorSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CollectionFeatureExtractorSamples.kt index 4a97d82ee5..4d9ee79157 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CollectionFeatureExtractorSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CollectionFeatureExtractorSamples.kt @@ -38,6 +38,7 @@ class CollectionFeatureExtractorSamples { fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + expect(listOf(1, 2, 3)) size { // subject inside this expectation-group is of type Int (actually 3) it toBeLessThan 1 // fails it toBeGreaterThan 4 // isLessThan 1 fails, but isGreaterThan 4 still evaluated diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/IterableSubjectChangerSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/IterableSubjectChangerSamples.kt index ce2e6c5a07..6a5496873e 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/IterableSubjectChangerSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/IterableSubjectChangerSamples.kt @@ -21,20 +21,19 @@ class IterableSubjectChangerSamples { @Test fun asList() { - expect(0..2) - .asList { // subject within this expectation-group is of type List - it toEqual listOf(0, 1, 2) - } // subject here is back to type IntRange + expect(0..2).asList { // subject within this expectation-group is of type List + it toEqual listOf(0, 1, 2) + } // subject here is back to type IntRange fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(0..2) - .asList { - it toContain 3 // fails - it toContain 4 // still evaluated even though above `toContain` already fails - // use `asList o` if you want a fail fast behaviour - } + + expect(0..2).asList { + it toContain 3 // fails + it toContain 4 // still evaluated even though above `toContain` already fails + // use `asList o` if you want a fail fast behaviour + } } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryFeatureExtractorSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryFeatureExtractorSamples.kt index 154ae38eba..86203bd3de 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryFeatureExtractorSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryFeatureExtractorSamples.kt @@ -1,9 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.samples -import ch.tutteli.atrium.api.infix.en_GB.key -import ch.tutteli.atrium.api.infix.en_GB.toEqual -import ch.tutteli.atrium.api.infix.en_GB.toEqualKeyValue -import ch.tutteli.atrium.api.infix.en_GB.value +import ch.tutteli.atrium.api.infix.en_GB.* import ch.tutteli.atrium.api.verbs.expect import kotlin.test.Test @@ -29,12 +26,12 @@ class MapEntryFeatureExtractorSamples { val entry = mapOf(1 to "a").entries.first() expect(entry).key { // subject inside this expectation-group is of type Int (actually 1) - this toEqual 1 + it toEqual 1 } // subject here is back to type Map.Entry fails { // because 1 is not equal to 2 expect(entry).key { // subject inside this expectation-group is of type Int (actually 1) - this toEqual 2 + it toEqual 2 } } } @@ -59,12 +56,16 @@ class MapEntryFeatureExtractorSamples { val entry = mapOf(1 to "a").entries.first() expect(entry) value { // subject inside this expectation-group is of type String (actually "a") - this toEqual "a" + it toEqual "a" } // subject here is back to type Map.Entry fails { // because "a" is not equal to "b" - expect(entry) value { // subject inside this expectation-group is of type String (actually "a") - this toEqual "b" + // all expectations are evaluated inside an expectation-group block; for more details: + // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group + + expect(entry) value { + it toEqual "b" // fails + it toEqual "c" // stil evaluated } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapFeatureExtractorSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapFeatureExtractorSamples.kt index e56605dd82..54fd1c4c7f 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapFeatureExtractorSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapFeatureExtractorSamples.kt @@ -30,9 +30,10 @@ class MapFeatureExtractorSamples { this toEqual "a" } - fails { - expect(mapOf(1 to "a")) getExisting key(1) { // subject inside this expectation-group is of type String (actually "a") - this toEqual "b" // fails because "a" is not equal to "b" + fails { // because key 2 does not exist but... + + expect(mapOf(1 to "a")) getExisting key(2) { + this toEqual "a" //... still reported as we are inside an expectation-group block } } @@ -40,11 +41,12 @@ class MapFeatureExtractorSamples { // all expectations are evaluated inside an expectation-group block; for more details: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(mapOf(1 to "a")) getExisting key(2) { // fails because key 2 does not exist - this toEqual "a" // still evaluated because we use an expectation-group block - // use `.getExisting(key).` if you want a fail fast behaviour + expect(mapOf(1 to "a")) getExisting key(1) { + it toEqual "b" // fails because "a" is not equal to "b" + it toEqual "c" // still evaluated, use `getExisting 1` if you want a fail fast behaviour } } + } @Test @@ -62,7 +64,7 @@ class MapFeatureExtractorSamples { @Test fun keys() { expect(mapOf(1 to "a")) keys { // subject inside this expectation-group is of type Set (containing 1) - this toEqual setOf(1) + it toEqual setOf(1) } fails { @@ -70,9 +72,9 @@ class MapFeatureExtractorSamples { // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group expect(mapOf(1 to "a")) keys { // subject inside this expectation-group is of type Set (containing 1) - this toEqual setOf(2) // fails because 1 is not equal to 2 - this toHaveSize 3 // still evaluated because we use an expectation-group block - // use `.keys.` if you want a fail fast behaviour + it toEqual setOf(2) // fails because 1 is not equal to 2 + it toHaveSize 3 // still evaluated because we use an expectation-group block + // use `.keys ` if you want a fail fast behaviour } } } @@ -101,7 +103,7 @@ class MapFeatureExtractorSamples { expect(mapOf(1 to "a")) values { // subject inside this expectation-group is of type Collection (containing <"a">) this toEqual setOf("b") // fails because "a" is not equal to "b" - // use `.values.` if you want a fail fast behaviour + // use `.values ` if you want a fail fast behaviour } } } @@ -143,7 +145,12 @@ class MapFeatureExtractorSamples { @Test fun size() { - expect(mapOf(1 to "a", 2 to "b")) size { // subject inside this expectation-group is of type Int (containing 2) + expect( + mapOf( + 1 to "a", + 2 to "b" + ) + ) size { // subject inside this expectation-group is of type Int (containing 2) this toEqual 2 this toBeGreaterThan 1 } @@ -153,9 +160,9 @@ class MapFeatureExtractorSamples { // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group expect(mapOf(1 to "a")) size { // subject inside this expectation-group is of type Int (containing 1) - this toEqual 2 // fails because 1 is not equal to 2 - this toBeLessThan 0 // fails because 1 is not less than 0 - // use `.size.` if you want a fail fast behaviour + this toEqual 2 // fails because 1 is not equal to 2 + this toBeLessThan 0 // fails because 1 is not less than 0 + // use `.size ` if you want a fail fast behaviour } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/PairFeatureExtractorSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/PairFeatureExtractorSamples.kt index 8245e2ad96..6926ffdcb9 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/PairFeatureExtractorSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/PairFeatureExtractorSamples.kt @@ -38,12 +38,12 @@ class PairFeatureExtractorSamples { fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(pair) - .first { // subject inside this expectation-group is of type Int (actually 1) - it toBeGreaterThan 2 //fails - it toBeLessThan 0 // still evaluated even though `toBeGreaterThan` already fails - // use ` first o` if you want a fail fast behaviour - } + + expect(pair).first { // subject inside this expectation-group is of type Int (actually 1) + it toBeGreaterThan 2 //fails + it toBeLessThan 0 // still evaluated even though `toBeGreaterThan` already fails + // use ` first o` if you want a fail fast behaviour + } } } @@ -82,12 +82,12 @@ class PairFeatureExtractorSamples { fails { // all expectations inside an expectation-group are evaluated together; for more details see: // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group - expect(pair) - .second { // subject inside this expectation-group is of type Int (actually 1) - it toBeGreaterThan 2 // fails - it toBeLessThan 0 // still evaluated even though `toBeGreaterThan` already fails, - // use ` second o` if you want a fail fast behaviour - } + + expect(pair).second { // subject inside this expectation-group is of type Int (actually 1) + it toBeGreaterThan 2 // fails + it toBeLessThan 0 // still evaluated even though `toBeGreaterThan` already fails, + // use ` second o` if you want a fail fast behaviour + } } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ResultExpectationSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ResultExpectationSamples.kt index bdf3060085..23deb65a2e 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ResultExpectationSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/ResultExpectationSamples.kt @@ -100,21 +100,21 @@ class ResultExpectationSamples { expect(failure).toBeAFailure { its messageToContain "parameter" // fails its.message toStartWith "wrong" // still evaluated even though messageToContain already fails - // use `.toBeAFailure.` if you want a fail fast behaviour + // use `.toBeAFailure ` if you want a fail fast behaviour } } fails { // because wrong Expectation type expected, but since we use an expectation-group... expect(failure).toBeAFailure { its messageToContain "parameter" // ...reporting mentions that subject's message was expected `to contain: "parameter"`` - // use `.toBeAFailure.` if you want a fail fast behaviour + // use `.toBeAFailure ` if you want a fail fast behaviour } } fails { // because it was a Success, but since we use a block expect(Result.success(10)).toBeAFailure { its messageToContain "parameter" // ...reporting mentions that subject's message was expected `to contain: "parameter"`` - // use `.toBeAFailure.` if you want a fail fast behaviour + // use `.toBeAFailure ` if you want a fail fast behaviour } } } diff --git a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/SequenceSubjectChangerSamples.kt b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/SequenceSubjectChangerSamples.kt index 93202c85be..6f18a8edaf 100644 --- a/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/SequenceSubjectChangerSamples.kt +++ b/apis/infix/atrium-api-infix/src/commonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/SequenceSubjectChangerSamples.kt @@ -29,11 +29,9 @@ class SequenceSubjectChangerSamples { } // subject is back to Sequence fails { - expect(sequenceOf(1, 2, 3)) - .asIterable { //subject within this expectation-group is of type Iterable - - it toContain 4 - } //subject here is back to type Sequence + expect(sequenceOf(1, 2, 3)).asIterable { //subject within this expectation-group is of type Iterable + it toContain 4 + } //subject here is back to type Sequence } } @@ -45,11 +43,9 @@ class SequenceSubjectChangerSamples { @Test fun asList() { - expect(sequenceOf(1, 2, 3)) - - .asList { //subject within this expectation group is of type List - toEqual(listOf(1, 2, 3)) - } //subject here is back to type to Sequence + expect(sequenceOf(1, 2, 3)).asList { //subject within this expectation group is of type List + toEqual(listOf(1, 2, 3)) + } //subject here is back to type to Sequence } }