Description
UtBot tries to mock parameter which type is interface without existing implementations. As Do not mock selected no Mockito dependencies are added and so generated code cannot be executed.
To Reproduce
Steps to reproduce the behavior:
- Open some test project which has NO Mockito dependencies in it
- Generate tests for code below, select
Do not mock option
public class CommonMocksExample {
public Object mockInterfaceWithoutImplementors(InterfaceWithoutImplementors value) {
return value.visit(this);
}
}
interface InterfaceWithoutImplementors {
Object visit(Object value);
}
Expected behavior
Generated tests have no mocks and can be executed. Or no tests are generated.
Actual behavior
Generated tests shown below. It contains references to Mockito when and actual, but because there is no Mockito dependency in the project, such tests cannot be executed.
@Test
@DisplayName("mockInterfaceWithoutImplementors: InterfaceWithoutImplementorsVisit -> return value.visit(this)")
public void testMockInterfaceWithoutImplementors_InterfaceWithoutImplementorsVisit() {
CommonMocksExample commonMocksExample = new CommonMocksExample();
InterfaceWithoutImplementors valueMock = mock(InterfaceWithoutImplementors.class);
(when(valueMock.visit(any()))).thenReturn(null);
Object actual = commonMocksExample.mockInterfaceWithoutImplementors(valueMock);
assertNull(actual);
}
Visual proofs (screenshots, logs, images)

Environment
IDEA 2022.2.3
UTBot 2022.12.637 from unit-test-bot/rc16122022 branch
Additional context
That seems quite old bug, as it's reproducible in 2022.10.580 version of UTBot too.
Description
UtBot tries to mock parameter which type is interface without existing implementations. As
Do not mockselected no Mockito dependencies are added and so generated code cannot be executed.To Reproduce
Steps to reproduce the behavior:
Do not mockoptionExpected behavior
Generated tests have no mocks and can be executed. Or no tests are generated.
Actual behavior
Generated tests shown below. It contains references to Mockito
whenandactual, but because there is no Mockito dependency in the project, such tests cannot be executed.Visual proofs (screenshots, logs, images)

Environment
IDEA 2022.2.3
UTBot 2022.12.637 from unit-test-bot/rc16122022 branch
Additional context
That seems quite old bug, as it's reproducible in 2022.10.580 version of UTBot too.