-
Notifications
You must be signed in to change notification settings - Fork 379
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
equalTo() Should Not Force Type Match of Actual to Compile #59
Comments
you have a point. There are tradeoffs in that the typed version will catch some mistakes at compile time and works better with jmock (our original client). I'm now beginning to think that jMock should have had its own matcher methods, but it's a bit late now. |
What will break if the signature of |
People using |
What do you think a good solution would be? |
The only solution is to add another matcher factory method. E.g. isEqualToObject(Object o) -> Matcher |
Implemented in master. |
Currently,
equalTo()
will not compile when comparingObject
to another class forcing unnecessary casting. For example:HttpServletRequest request = (get request);
Object actual = request.getAttribute("SomeAttribute");
assertThat(actual, equalTo((Object) fooInstance));
In this example, the compile will fail unless
fooInstance
is cast toObject
. But this is unnecessary forequals()
to work correctly.If the signature of
equalsTo()
were:Matcher<Object> equalTo(Object o)
it could avoid the above problem.
The text was updated successfully, but these errors were encountered: