-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Closed
Copy link
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
To Reproduce
Consider generating unit tests for project spring-boot-testing with modified OrderService class.
@Service
public class OrderService {
@Autowired
private OrderRepository orderRepository;
private List<Order> baseOrders = new ArrayList<>();
public int getOrdersCount() { return orderRepository.findAll().size() + baseOrders.size(); }
}Expected behavior
Happy pass test is generated with correct assertions.
Actual behavior
The following failing test is generated.
It fails because real number of items in collection is 3, not 6.
@Test
@DisplayName("getOrdersCount: OrderRepositoryFindAll -> return orderRepository.findAll().size() + baseOrders.size()")
public void testGetOrdersCount_ListSize() {
ArrayList arrayList1 = new ArrayList();
arrayList1.add(null);
arrayList1.add(null);
arrayList1.add(null);
(when(orderRepositoryMock.findAll())).thenReturn(arrayList1);
int actual = orderService.getOrdersCount();
assertEquals(6, actual);
}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