While working on a fix for #102 I noticed that the following test fails:
@RepeatedTest(10)
void issue103() {
var sut = Fixture.fixture().create(Closeable.class);
assertThat(sut).isEqualTo(sut);
}
This fails for interfaces and abstract classes because we create a proxy that returns a random value for any called method.
You have to run it multiple times, because the result of equals is a random boolean, so for some created fixtures it's true, for others it's false.
If we create random values for this, we violate the Java contract for equals and hashCode. This might lead to unexpected behaviour.
I believe this should be fixed before the fix for #102 can be merged.
While working on a fix for #102 I noticed that the following test fails:
This fails for interfaces and abstract classes because we create a proxy that returns a random value for any called method.
You have to run it multiple times, because the result of
equalsis a random boolean, so for some created fixtures it's true, for others it's false.If we create random values for this, we violate the Java contract for
equalsandhashCode. This might lead to unexpected behaviour.I believe this should be fixed before the fix for #102 can be merged.