public class TestEqualToByComparingFields {
public static class X {
public X(String message) {
this.message = message;
}
private String message;
}
@Test
public void testIsEqualToByComparingFields() {
X x1 = new X("1");
X x2 = new X("2");
assertThat(x1).isEqualsToByComparingFields(x2);
}
}
By my reading of the that method, "isEqualsToByComparingFields" this test should fail as message field is different.
However, the test passes.
It is only when I add the getter and the setter for that field message that the test fails.
Should the method not be named "isEqualsToByComparingProperties"? since it's not actually comparing fields but using the getters and setters for comparison.
I had a look at the method and it uses BeanInfo - so it is definitely only comparing on getters and setters.
I assume this is by design but it does make the method name misdirecting?
I've also bumped into this, the name of the assertion is really misleading and providing one that really does use fields for comparison and ignores properties would be appreciated.
Consider...
By my reading of the that method, "isEqualsToByComparingFields" this test should fail as message field is different.
However, the test passes.
It is only when I add the getter and the setter for that field message that the test fails.
Should the method not be named "isEqualsToByComparingProperties"? since it's not actually comparing fields but using the getters and setters for comparison.
I had a look at the method and it uses BeanInfo - so it is definitely only comparing on getters and setters.
I assume this is by design but it does make the method name misdirecting?
btw, I do really like this library :+1: