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

Equalsverifier fails on enum #87

Closed
GoogleCodeExporter opened this issue Mar 29, 2015 · 7 comments
Closed

Equalsverifier fails on enum #87

GoogleCodeExporter opened this issue Mar 29, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. implement an enum (without equals method)
2. run equalsverifier on it
3. you will get identical-copy and symmetry warning
4. you will need to use 
EqualsVerifier.forClass(myclass).withRedefinedSuperclass().suppress(Warning.IDEN
TICAL_COPY).verify();

I would expect equalsverifier to work out-of-the-box for enums that don't 
overwrite equals()

Original issue reported on code.google.com by [email protected] on 8 Mar 2014 at 11:23

@GoogleCodeExporter
Copy link
Author

I never implemented this because Java itself guarantees that enums always have 
a correct equals implementation. In fact, you can't even override equals in an 
enum. Using EqualsVerifier to verify that, always seemed a bit pointless to me.
That said, it would be easy enough to fix this.

What use case do you have for this?

Original comment by [email protected] on 9 Mar 2014 at 10:43

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

My use case is, that I provide an annotated base-class for all my unit-tests. 
It has (amongst other things) a testEqualsContract which is executed for all 
subclasses and thus for all my test-cases.
This works fine for most of my test-cases, but not for those testing enums. In 
those I need to overwrite that method with the mentioned "work-around"

Original comment by [email protected] on 9 Mar 2014 at 9:21

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

OK, that makes sense. I'll fix this in the next release.
Thanks for reporting it!

Original comment by [email protected] on 10 Mar 2014 at 9:37

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Thanks for accepting it :-)
Btw. the same would be the case for classes not implementing hashCode/equals 
(have not yet fallen into that pit :-) )

Original comment by [email protected] on 10 Mar 2014 at 10:51

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

I've been thinking about that too, but unfortunately it conflicts with Issue 66.
I could add a flag though, so that it also works for this scenario. I'll think 
about it :).

Original comment by [email protected] on 11 Mar 2014 at 11:51

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

I've fixed the enum part in version 1.4.1 which I've just released. The object 
part, I'll leave for another time.

Original comment by [email protected] on 18 Mar 2014 at 11:40

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Perfect - thanks :-)

Original comment by [email protected] on 18 Mar 2014 at 5:21

  • Added labels: ****
  • Removed labels: ****

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

No branches or pull requests

1 participant