diff --git a/assertk/src/jvmMain/kotlin/assertk/assertions/any.kt b/assertk/src/jvmMain/kotlin/assertk/assertions/any.kt index 39b817df..3b20213f 100644 --- a/assertk/src/jvmMain/kotlin/assertk/assertions/any.kt +++ b/assertk/src/jvmMain/kotlin/assertk/assertions/any.kt @@ -97,13 +97,13 @@ private fun Assert.isDataClassEqualToImpl(expected: T, kclass: KClass<*>? /** * Returns an assert that compares all accessible properties except the given properties on the calling class. * @param other Other value to compare to - * @param properties properties of the type with which been ignored + * @param properties properties of the type which will be ignored during comparison * * ``` * assertThat(person).isEqualToIgnoringGivenProperties(other, Person::name, Person::age) * ``` */ -fun Assert.isEqualToIgnoringGivenProperties(other: T, vararg properties: KProperty1) { +fun Assert.isEqualToIgnoringGivenProperties(other: T, vararg properties: KProperty1) { all { for (prop in other::class.memberProperties) { if (!properties.contains(prop)) { diff --git a/assertk/src/jvmTest/kotlin/test/assertk/assertions/JavaAnyTest.kt b/assertk/src/jvmTest/kotlin/test/assertk/assertions/JavaAnyTest.kt index 8d3de13d..d733e76d 100644 --- a/assertk/src/jvmTest/kotlin/test/assertk/assertions/JavaAnyTest.kt +++ b/assertk/src/jvmTest/kotlin/test/assertk/assertions/JavaAnyTest.kt @@ -207,6 +207,22 @@ class JavaAnyTest { BasicObject::failing ) } + + @Test + fun isEqualToIgnoringGivenProperties_passes_subclass() { + fun testObject(): TestObject { + return BasicObject(str = "Rarity") + } + + assertThat( + testObject() + ).isEqualToIgnoringGivenProperties( + BasicObject(str = "notRarity"), + BasicObject::str, + BasicObject::other, + BasicObject::failing + ) + } //endregion open class TestObject