Closed
Description
Description
There are a lot of recreations of Injected mocks and mocks in Spring test methods.
To Reproduce
- Generate tests for OwnerController in spring-petclinic.
- Among generated tests there'll be ones with unnecessary recreations, e.g.
@InjectMocks
public OwnerController ownerController;
@Mock
public OwnerRepository ownerRepositoryMock;
@Test
@DisplayName("showOwner: IntegerValueOf -> return mav")
public void testShowOwner_ModelAndViewAddObject() throws ... {
MockedConstruction mockedConstruction = null;
try {
mockedConstruction = mockConstruction(...);
->OwnerRepository ownerRepositoryMock1 = mock(OwnerRepository.class);
(when(ownerRepositoryMock1.findById(any()))).thenReturn(((Owner) null));
->OwnerController ownerController1 = new OwnerController(ownerRepositoryMock1);
...
} finally {
...
}
}
Expected behavior
Already created variables must be used.
Metadata
Metadata
Assignees
Type
Projects
Status
Done