Skip to content

HashCode of a mocked object is used in path constraints #286

Open
@alisevych

Description

@alisevych

Description

DoNotMockHashCode is failing on ExampleClass. hashCode of the mocked object is returning.

To Reproduce

Steps to reproduce the behavior:

  1. Run IntelliJ IDEA
  2. Open UTBotJava project
  3. Open the utbot-sample/src/main/java/org/utbot/examples/mock/CommonMocksExample.java file
  4. Generate tests for doNotMockHashCode with "Other packages: Mockito" and "No static mocking"
  5. Run the generated test

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:

 @Override
    public int hashCode() {
        return 100 * 31;
    }

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions