-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorcomp-springIssue is related to Spring projects supportIssue is related to Spring projects supportctg-bugIssue is a bugIssue is a bug
Milestone
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
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorcomp-springIssue is related to Spring projects supportIssue is related to Spring projects supportctg-bugIssue is a bugIssue is a bug
Type
Projects
Status
Done