Closed
Description
Description
Generated Unit test for Spring project is expected to throw MockitoException, but the test passes.
To Reproduce
- Install UnitTestBot plugin built from main in IntelliJ IDEA
- Open Medical-Web-App project
- Generate tests for
MirfController
withUnit tests
andMedicalWebApp
configuration selected - Run
ERROR SUITE for method getResultFromPipeline
Expected behavior
There should be no such test present on MockitoException.
It should be included into Successful executions suite (or excluded as a duplicate).
Actual behavior
The test on MockitoException passes.
Screenshots, logs
@Test
public void testGetResultFromPipeline1() throws Exception {
((doNothing()).when(loggerMock)).info(any(String.class), any(Object.class), any(Object.class));
ArrayList arrayList = new ArrayList();
PipelineJob pipelineJob = ((PipelineJob) createInstance("com.app.medicalwebapp.model.PipelineJob"));
String string = "";
pipelineJob.setMirfSessionid(string);
arrayList.add(pipelineJob);
(when(pipelineJobRepositoryMock.findAll())).thenReturn(arrayList);
(when(pipelineJobRepositoryMock.findByMirfSessionid(any()))).thenReturn(arrayList);
MultipartFile resultZipFileMock = mock(MultipartFile.class);
InputStream inputStreamMock = mock(InputStream.class);
byte[] byteArray = {
(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0,
(byte) 0
};
(when(inputStreamMock.readAllBytes())).thenReturn(byteArray);
(when(resultZipFileMock.getInputStream())).thenReturn(inputStreamMock);
(when(resultZipFileMock.getSize())).thenReturn(0L);
/* This test fails because method [com.app.medicalwebapp.clients.mirf.MirfController.getResultFromPipeline] produces [org.mockito.exceptions.base.MockitoException:
Cannot call abstract real method on java object!
Calling real methods is only possible when mocking non abstract method.
//correct example:
when(mockOfConcreteClass.nonAbstractMethod()).thenCallRealMethod();]
org.utbot.instrumentation.instrumentation.execution.constructors.InstrumentationContextAwareValueConstructor$generateMockitoAnswer$1.answer(InstrumentationContextAwareValueConstructor.kt:217)
com.app.medicalwebapp.clients.mirf.MirfController.getResultFromPipeline(MirfController.java:65) */
mirfController.getResultFromPipeline(null, resultZipFileMock);
}
Environment
IntelliJ IDEA version - Ultimate 2023.2
Project - Maven
JDK - 11
Metadata
Metadata
Assignees
Type
Projects
Status
Done