npx skills add smithery/pluginagentmarketplace --skill java-testing
pluginagentmarketplace/custom-plugin-java
java-testing
Test Java applications - JUnit 5, Mockito, integration testing, TDD patterns
Installation
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-testing
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Browser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
810.4K installsConfigure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: sem…
566.3K installsAzure VM/VMSS router. WHEN: create / provision / deploy / spin-up VM, recommend VM size, compar…
510K installsPostgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill …
391.6K installsPrisma ORM CLI commands reference covering init, generate, migrate, db, dev, complete, studio, …
267K installsUse when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge F…
263K installsAlso in this package
Other skills from pluginagentmarketplace/custom-plugin-java · top by installs.
npx skills add pluginagentmarketplace/custom-plugin-java
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
main
Skill metadata
Parsed from SKILL.md frontmatter.
Read, Write, Bash, Glob, GrepPackage contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md5,516 B -
docs
SUMMARY.md93 B
History
- First seen on skills.sh
- First recorded snapshot · 854 installs
SKILL.md
Java Testing Skill
Write comprehensive tests for Java applications with modern testing practices.
Overview
This skill covers Java testing with JUnit 5, Mockito, AssertJ, and integration testing with Spring Boot Test and Testcontainers. Includes TDD patterns and test coverage strategies.
When to Use This Skill
Use when you need to:
- Write unit tests with JUnit 5
- Create mocks with Mockito
- Build integration tests with Testcontainers
- Implement TDD/BDD practices
- Improve test coverage
Topics Covered
JUnit 5
- @Test, @Nested, @DisplayName
- @ParameterizedTest with sources
- Lifecycle annotations
- Extensions and custom annotations
Mockito
- @Mock, @InjectMocks, @Spy
- Stubbing (when/thenReturn)
- Verification (verify, times)
- BDD style (given/willReturn)
AssertJ
- Fluent assertions
- Collection assertions
- Exception assertions
- Custom assertions
Integration Testing
- @SpringBootTest slices
- Testcontainers setup
- MockMvc for APIs
- Database testing
Quick Reference
// Unit Test with Mockito
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
@Mock
private UserRepository userRepository;
@InjectMocks
private UserService userService;
@Test
@DisplayName("Should find user by ID")
void shouldFindUserById() {
// Given
User user = new User(1L, "John");
given(userRepository.findById(1L)).willReturn(Optional.of(user));
// When
Optional<User> result = userService.findById(1L);
// Then
assertThat(result)
.isPresent()
.hasValueSatisfying(u ->
assertThat(u.getName()).isEqualTo("John"));
then(userRepository).should().findById(1L);
}
}
// Parameterized Test
@ParameterizedTest
@CsvSource({
"[email protected], true",
"invalid-email, false",
"'', false"
})
void shouldValidateEmail(String email, boolean expected) {
assertThat(validator.isValid(email)).isEqualTo(expected);
}
// Integration Test with Testcontainers
@Testcontainers
@SpringBootTest
class OrderRepositoryIT {
@Container
static PostgreSQLContainer<?> postgres =
new PostgreSQLContainer<>("postgres:15");
@DynamicPropertySource
static void configure(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
}
@Autowired
private OrderRepository repository;
@Test
void shouldPersistOrder() {
Order saved = repository.save(new Order("item", 100.0));
assertThat(saved.getId()).isNotNull();
}
}
// API Test with MockMvc
@WebMvcTest(UserController.class)
class UserControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private UserService userService;
@Test
void shouldReturnUser() throws Exception {
given(userService.findById(1L))
.willReturn(Optional.of(new User(1L, "John")));
mockMvc.perform(get("/api/users/1"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("John"));
}
}
Test Data Builders
public class UserTestBuilder {
private Long id = 1L;
private String name = "John Doe";
private String email = "[email protected]";
private boolean active = true;
public static UserTestBuilder aUser() {
return new UserTestBuilder();
}
public UserTestBuilder withName(String name) {
this.name = name;
return this;
}
public UserTestBuilder inactive() {
this.active = false;
return this;
}
public User build() {
return new User(id, name, email, active);
}
}
// Usage
User user = aUser().withName("Jane").inactive().build();
Coverage Goals
<!-- JaCoCo configuration -->
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
Troubleshooting
Common Issues
| Problem | Cause | Solution |
|---|---|---|
| Mock not working | Missing @ExtendWith | Add MockitoExtension |
| NPE in test | Mock not initialized | Check @InjectMocks |
| Flaky test | Shared state | Isolate test data |
| Context fails | Missing bean | Use @MockBean |
Debug Checklist
□ Run single test in isolation
□ Check mock setup matches invocation
□ Verify @BeforeEach setup
□ Review @Transactional boundaries
□ Check for shared mutable state
Usage
Skill("java-testing")
Related Skills
java-testing-advanced- Advanced patternsjava-spring-boot- Spring test slices