Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong assertion in EqualsHashCodeContractAssert #1455

Closed
ghostd opened this issue Mar 5, 2019 · 3 comments
Closed

Wrong assertion in EqualsHashCodeContractAssert #1455

ghostd opened this issue Mar 5, 2019 · 3 comments

Comments

@ghostd
Copy link
Contributor

ghostd commented Mar 5, 2019

Hi,

I read the class EqualsHashCodeContractAssert, and since equals returns a boolean, i think

public static void assertIsNotEqualToNull(Object obj) {
    assertThat(obj.equals(null)).isNull();
}

should be

public static void assertIsNotEqualToNull(Object obj) {
    assertThat(obj.equals(null)).isFalse();
}

If you didn't spot the bug, i guess this is dead code.

Regards

@ghostd
Copy link
Contributor Author

ghostd commented Mar 5, 2019

By the way, did you consider expose those assertions in the public API to check the equals contract?

@joel-costigliola
Copy link
Member

Good catch! The code is dead code indeed, it was written in Fest Assert which AssertJ is a fork of.

I think it is better to use https://jqno.nl/equalsverifier/ to test equals and hashcode, no plan in the roadmap to support this.

@ghostd
Copy link
Contributor Author

ghostd commented Mar 5, 2019

Ok, thanks for the pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants