Closed
Description
Description
Let's generate tests for the following code:
private EntityManager em;
public List<User> listUsers() {
return em.createQuery("from User ", User.class).getResultList();
}
UtBot automatically detects that it is a Spring project, NoConfiguration
mode is selected.
Generated test looks as follows:
@Mock
public TypedQuery typedQueryMock;
@Test
@DisplayName("listUsers: EntityManagerCreateQuery -> return em.createQuery(\"from User \", User.class).getResultList()")
public void testListUsers_TypedQueryGetResultList() {
(when(entityManagerMock.createQuery(any(), any()))).thenReturn(typedQueryMock);
List actual = userDaoImp.listUsers();
assertNull(actual);
}
TypedQuery
type fully qualified name is javax.persistence.TypedQuery
Expected behavior
UtBot generates only passing tests.
Actual behavior
Generated test fails on the assertion.
Visual proofs (screenshots, logs, images)
Additional context
The problem requires investigation, there are several possible situations:
- assertion is correct, but mocking is configured badly
- assertion is generated incorrectly
- there is a bug in engine that leads to incorrect test
Metadata
Metadata
Assignees
Type
Projects
Status
Done