I have a class like this:
data class Thing(val name: String, val complexObject: ComplexType? = null)
And a test like this:
import nl.jqno.equalsverifier.EqualsVerifier
import org.junit.Test
class ThingTest {
@Test
fun `test equals and hashCode`() {
EqualsVerifier.forClass(Thing::class.java)
.verify()
}
}
Now I want to completely ignore complexObject
in EqualsVerifier. It’s a type it cannot instantiate, and it asks me to provide a prefab object (withPrefabValues
) for it. This would work, but my Thing
is used in a lot of places and other people write a lot of tests for classes that contain a Thing
, and the complexObject
should be none of their concern. Comparisons of this object are not necessary for these downstream tests to work.
Can I somehow mark complexObject
as always being null
for the purposes of EqualsVerifier?
Ideally without touching all tests which verify objects which transitively use a Thing
, but if it’s only possible test by test, then this would already be an improvement over having to pass a prefab object every time (because withPrefabValues
needs at least one real object that is not null).