Install any skill in seconds. Free to start, no credit card required.
Get Started Free →giuseppe-trisciuoglio/unit-test-service-layer
Provides patterns for unit testing service layer with Mockito. Creates isolated tests that mock repository calls, verify method invocations, test exception scenarios, and stub external API responses.
Passed 22 of 22 test cases with the skill, and 18 of 22 without it.
and 4 more in the full report
4 fixed18 passed either way0 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
I have a Spring `OrderService` class that processes customer orders using an `OrderRepository` and an external `PaymentGatewayClient`. Can you generate a complete JUnit 5 test class to verify its `processOrder` method? I need tests for the successful payment and order save scenario, as well as when the payment fails and throws a custom exception. Please ensure the tests run isolated without spinning up Spring Context or database connections, returning standard Java test code.
| Checked | Without skill | With skill |
|---|---|---|
| Uses AssertJ assertThat assertions for verifying returned objects. | Missed | Passed |
| Uses AssertJ assertThatThrownBy assertions for testing exception scenarios. | Missed | Passed |
The instructions your model reads when the skill loads.
Provides patterns for unit testing @Service classes using Mockito. Mocks repository calls, verifies method invocations, tests exception scenarios, and stubs external API responses. Enables fast, isolated tests without Spring container or database.
@Service classesFollow this workflow to test service layer with Mockito, including validation checkpoints:
Use @ExtendWith(MockitoExtension.class) to enable Mockito annotations.
@Mock and @InjectMocksUse @Mock for dependencies (repositories, clients) and @InjectMocks for the service under test.
Arrange: Create test data and configure mock return values using when().thenReturn().
Act: Execute the service method being tested.
Assert:
verify()Configure mocks to throw exceptions with when().thenThrow().
test cases passed, vs 18 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.