Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers Java test structure, naming, Mockito, @WebMvcTest, @DataJpaTest and Testcontainers across unit, slice and integration tests.
68% 100%+32 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 15 of 22 without it.
This test ran on v2. v8 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
Not used yet
Unit Tests — fast domain logic checks without a Spring context
Slice Tests — focused web or persistence infrastructure checks
Integration Tests — cross-boundary behavior with real dependencies
Choose the mix by risk, not a fixed percentage. Use real database/Redis tests for concurrency, serialization and transaction semantics that mocks cannot establish. Preserve the project's JUnit/AssertJ and mocking conventions; changing assertion libraries is not a correctness fix.
@ExtendWith(MockitoExtension.class)
class OrderServiceTest {
@Mock private OrderRepository orderRepository;
@Mock private InventoryService inventoryService;
@InjectMocks private OrderService orderService;
@Test
void createOrder_whenItemsAvailable_shouldSaveAndReturnOrder() {
// Given
var request = new CreateOrderRequest("[email protected]", List.of(new OrderItemRequest(UUID.randomUUID(), 2)));
var savedOrder = Order.create("[email protected]");
when(orderRepository.save(any(Order.class))).thenReturn(savedOrder);
doNothing().when(inventoryService).reserve(any());
// When
Order result = orderService.createOrder(request);
// Then
assertThat(result).isNotNull();
assertThat(result.getCustomerEmail()).isEqualTo("[email protected]");
verify(inventoryService).reserve(request.items());
Next to this one in the catalogue, plus more from the same author.