Description
When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests.
To Reproduce
Steps to reproduce the behavior:
- Run IntelliJ IDEA 2022.1.4 with one of the latest builds of UTBot plugin from main branch installed.
- Open UTBotJava project
- Find utbot-sample/src/main/java/org/utbot/examples/mock/CommonMocksExample.java
- Generate tests for nextValue() method with Mocking strategy is set to "Other classes: Mockito"
- Open the generated test
Expected behavior
RecursiveTypeClass used as the input parameter of the method is supposed to be mocked in all tests - except the one with null used.
Actual behavior
There are 4 tests generated. RecursiveTypeClass is mocked only in one test.
Visual proofs (screenshots, logs, images)
publicclassCommonMocksExampleTest {
@TestpublicvoidtestNextValue() {
CommonMocksExamplecommonMocksExample = newCommonMocksExample();
RecursiveTypeClassnode = newRecursiveTypeClass();
RecursiveTypeClassrecursiveTypeClass = newRecursiveTypeClass();
recursiveTypeClass.next = null;
recursiveTypeClass.value = 0;
node.next = recursiveTypeClass;
node.value = 0;
RecursiveTypeClassactual = commonMocksExample.nextValue(node);
RecursiveTypeClassnodeNext = node.next;
RecursiveTypeClassactualNext = actual.next;
RecursiveTypeClassactualNextNext = actualNext.next;
assertNull(actualNextNext);
intnodeNextValue = nodeNext.value;
intactualNextValue = actualNext.value;
assertEquals(nodeNextValue, actualNextValue);
intnodeValue = node.value;
intactualValue = actual.value;
assertEquals(nodeValue, actualValue);
}
@TestpublicvoidtestNextValueThrowsNPE() {
CommonMocksExamplecommonMocksExample = newCommonMocksExample();
RecursiveTypeClassnode = newRecursiveTypeClass();
/* This test fails because method [org.utbot.examples.mock.CommonMocksExample.nextValue] produces [java.lang.NullPointerException] org.utbot.examples.mock.CommonMocksExample.nextValue(CommonMocksExample.java:25) */commonMocksExample.nextValue(node);
}
@TestpublicvoidtestNextValue_NodeNextEqualsNode() {
CommonMocksExamplecommonMocksExample = newCommonMocksExample();
RecursiveTypeClassnodeMock = mock(RecursiveTypeClass.class);
nodeMock.next = nodeMock;
RecursiveTypeClassactual = commonMocksExample.nextValue(nodeMock);
intnodeMockValue = nodeMock.value;
intactualValue = actual.value;
assertEquals(nodeMockValue, actualValue);
}
@TestpublicvoidtestNextValue_ThrowNullPointerException() {
CommonMocksExamplecommonMocksExample = newCommonMocksExample();
/* This test fails because method [org.utbot.examples.mock.CommonMocksExample.nextValue] produces [java.lang.NullPointerException] org.utbot.examples.mock.CommonMocksExample.nextValue(CommonMocksExample.java:21) */commonMocksExample.nextValue(null);
}
}Environment
Windows 10 Pro
Gradle project
JDK 8
Additional context
When generating tests for MockWithFieldExample with same setting : Other classes : Mockito - VersionStamp is not mocked either
Description
When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
RecursiveTypeClass used as the input parameter of the method is supposed to be mocked in all tests - except the one with null used.
Actual behavior
There are 4 tests generated. RecursiveTypeClass is mocked only in one test.
Visual proofs (screenshots, logs, images)
Environment
Windows 10 Pro
Gradle project
JDK 8
Additional context
When generating tests for MockWithFieldExample with same setting : Other classes : Mockito - VersionStamp is not mocked either