Assertj-core: Add doesNotHaveSameHashCodeAs and doesNotHaveToString assertions

Created on 30 Oct 2020  路  7Comments  路  Source: assertj/assertj-core

Summary

I sugest to add _doesNotHaveSameHashCodeAs_ and _doesNotHaveToString_ assertions to reflect _isEqualTo_/_isNotEqualTo_. (With a shorter name maybe?)

Example

assertThat(foo).isEqualTo(foo);
assertThat(foo).hasSameHashCodeAs(foo);
assertThat(foo).hasToString(foo.toString());

// Would replace:
assertThat(foo).isNotEqualTo(bar);
assertThat(foo.hashCode()).isNotEqualTo(bar.hashCode());
assertThat(foo.toString()).isNotEqualTo(bar.toString());

// By:
assertThat(foo).isNotEqualTo(bar);
assertThat(foo).doesNotHaveSameHashCodeAs(bar);
assertThat(foo).doesNotHaveToString(bar.toString());
good first issue new feature

All 7 comments

Looks good to me, I can't think of shorter names.

Hi!
I would like to contribute to assertj, and it's my first time. I'm interested in working on this issue. Is this available for me?

@lykims sure it is, thanks! Please let us know if you need anything from us. I suggest working on one method at a time.

@scordio Is one pull request per method preferable?

@lykims yes, the review will be faster and you could reuse the feedback for the style of the second PR

@joel-costigliola This issue is half resolved. It was suggested to create one PR per assertion.

Should this issue be reopened so I could implement doesNotHaveToString next?

Yes, my bad, would be great

Was this page helpful?
0 / 5 - 0 ratings