Closed
Description
To Reproduce
Try to generate tests for the following method from open-source project spring-boot-testing-main
:
public Double getOrderPriceById(long id) throws Exception {
var order = orderRepository.findById(id);
if (order == null) {
throw new Exception("Order id is incorrect");
}
return order.get().getPrice();
}
Method findById has the following signature Optional<T> findById(ID id);
Expected behavior
Generated tests may be compiled successfully.
Actual behavior
Two of three generated tests starts with the following line, where optional
variable was never declared.
(when(orderRepositoryMock.findById(any()))).thenReturn(optional);
Additional context
Yuri recommends to ensure that we call setupInstrumentation
properly and to find problem around it.
Metadata
Metadata
Assignees
Type
Projects
Status
Done