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.
To Reproduce
Try to generate tests for the following method from open-source project
spring-boot-testing-main: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
optionalvariable was never declared.Additional context
Yuri recommends to ensure that we call
setupInstrumentationproperly and to find problem around it.