-
Notifications
You must be signed in to change notification settings - Fork 45
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
HashCode of a mocked object is used in path constraints #286
Comments
The problem occurs when we have a method that returns a hashcode of some mocked value or uses it in path conditions. In such cases, we will have path divergence since the engine takes information from the real methods of the value (we cannot mock I think the best way is to detect such situations inside the engine and generate resulting tests without assertion for expected values (with a remark about the reason). But seems like it is something that is not easy to do, so I suggest removing this bug from the release milestone if we haven't seen such situations in real (users') code and fixing it later. What do you think, @alisevych? |
Description
DoNotMockHashCode is failing on ExampleClass. hashCode of the mocked object is returning.
To Reproduce
Steps to reproduce the behavior:
doNotMockHashCode
with "Other packages: Mockito" and "No static mocking"Expected behavior
testDoNotMockHashCode_ExampleClassHashCode is passed
Actual behavior
testDoNotMockHashCode_ExampleClassHashCode fails on Assertion
hashcode of the mocked object is returned
Visual proofs (screenshots, logs, images)
hashCode is different in every run. Error message in log is like that:
expected: <1119242936> but was: <227290491>
Expected :1119242936
Actual :227290491
Environment
Java 8
Additional context
Even if we make ExampleClass::hashCode return a constant - there will be a random number in the test:
The text was updated successfully, but these errors were encountered: