diff --git a/CHANGELOG.md b/CHANGELOG.md index 968f6399..8ec1883c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - signature of `isIn` and `isNotIn` has been changed to ensure at least two items are supplied. - added assertions `isIn(Iterable)` and `isNotIn(Iterable)` - change `Assert.fail` return type to `Nothing`. +- `isIn` and `isNotIn` failure messages now report the actual value against the expected collection. ## [0.28.1] 2024-04-17 diff --git a/assertk/src/commonMain/kotlin/assertk/assertions/any.kt b/assertk/src/commonMain/kotlin/assertk/assertions/any.kt index b3d1214b..0ee65077 100644 --- a/assertk/src/commonMain/kotlin/assertk/assertions/any.kt +++ b/assertk/src/commonMain/kotlin/assertk/assertions/any.kt @@ -95,13 +95,13 @@ fun Assert.isNotSameInstanceAs(expected: Any?) = given { actual -> fun Assert.isIn(first: T, second: T, vararg rest: T) = given { actual -> val values = listOf(first, second, *rest) if (actual in values) return - expected(":${show(values)} to contain:${show(actual)}") + expected(":${show(actual)} to be in:${show(values)}") } @Deprecated("For binary compatibility", level = DeprecationLevel.HIDDEN) fun Assert.isIn(vararg values: T) = given { actual -> if (actual in values) return - expected(":${show(values)} to contain:${show(actual)}") + expected(":${show(actual)} to be in:${show(values)}") } @Deprecated("isIn with no values always fails", level = DeprecationLevel.ERROR) @@ -124,7 +124,7 @@ fun Assert.isIn(first: T) { */ fun Assert.isIn(values: Iterable) = given { actual -> if (actual in values) return - expected(":${show(values)} to contain:${show(actual)}") + expected(":${show(actual)} to be in:${show(values)}") } /** @@ -134,13 +134,13 @@ fun Assert.isIn(values: Iterable) = given { actual -> fun Assert.isNotIn(first: T, second: T, vararg rest: T) = given { actual -> val values = listOf(first, second, *rest) if (actual !in values) return - expected(":${show(values)} to not contain:${show(actual)}") + expected(":${show(actual)} to not be in:${show(values)}") } @Deprecated("For binary compatibility", level = DeprecationLevel.HIDDEN) fun Assert.isNotIn(vararg values: T) = given { actual -> if (actual !in values) return - expected(":${show(values)} to not contain:${show(actual)}") + expected(":${show(actual)} to not be in:${show(values)}") } @Deprecated("isNotIn with no values always succeeds", level = DeprecationLevel.ERROR) @@ -163,7 +163,7 @@ fun Assert.isNotIn(first: T) { */ fun Assert.isNotIn(values: Iterable) = given { actual -> if (actual !in values) return - expected(":${show(values)} to not contain:${show(actual)}") + expected(":${show(actual)} to not be in:${show(values)}") } /** diff --git a/assertk/src/commonTest/kotlin/test/assertk/assertions/AnyTest.kt b/assertk/src/commonTest/kotlin/test/assertk/assertions/AnyTest.kt index 94f55c8e..90399a23 100644 --- a/assertk/src/commonTest/kotlin/test/assertk/assertions/AnyTest.kt +++ b/assertk/src/commonTest/kotlin/test/assertk/assertions/AnyTest.kt @@ -135,7 +135,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isIn(isOut1, isOut2) } - assertEquals("expected:<[not test1, not test2]> to contain:", error.message) + assertEquals("expected: to be in:<[not test1, not test2]>", error.message) } @Test @@ -150,7 +150,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isIn(list) } - assertEquals("expected:<[not test1]> to contain:", error.message) + assertEquals("expected: to be in:<[not test1]>", error.message) } @Test @@ -165,7 +165,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isIn(list) } - assertEquals("expected:<[not test1, not test2]> to contain:", error.message) + assertEquals("expected: to be in:<[not test1, not test2]>", error.message) } @Test @@ -183,7 +183,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isNotIn(isOut1, isIn, isOut2) } - assertEquals("expected:<[not test1, test, not test2]> to not contain:", error.message) + assertEquals("expected: to not be in:<[not test1, test, not test2]>", error.message) } @Test @@ -198,7 +198,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isNotIn(list) } - assertEquals("expected:<[test]> to not contain:", error.message) + assertEquals("expected: to not be in:<[test]>", error.message) } @Test @@ -213,7 +213,7 @@ class AnyTest { val error = assertFailsWith { assertThat(subject).isNotIn(list) } - assertEquals("expected:<[not test1, test, not test2]> to not contain:", error.message) + assertEquals("expected: to not be in:<[not test1, test, not test2]>", error.message) } @Test