giuseppe-trisciuoglio/developer-kit / plugins/developer-kit-java/skills/unit-test-utility-methods
unit-test-utility-methods
VerifiedProvides patterns for testing utility classes, static methods, and helper functions. Validates pure functions, null handling, edge cases, and boundary conditions. Generates AssertJ assertions and @ParameterizedTest for string utils, math utils, validators, and collection helpers. Use when testing utils, test helpers, helper functions, static methods, or verifying utility code correctness.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.1 KB |
| references/edge-cases.md | markdown | 3.0 KB |
| references/parameterized-tests.md | markdown | 1.8 KB |
references/parameterized-tests.md
View on GitHub# Parameterized Tests for Utility Methods
Use `@ParameterizedTest` for testing multiple similar inputs efficiently.
## ValueSource - Single Parameter
```java
@ParameterizedTest
@ValueSource(strings = {"", " ", "null", " \t "})
void shouldConsiderFalsyValuesAsEmpty(String input) {
assertThat(StringUtils.isEmpty(input)).isTrue();
}
```
## CsvSource - Multiple Parameters
```java
@ParameterizedTest
@CsvSource({
"hello, HELLO",
"world, WORLD",
"test, TEST",
"123abc, 123ABC"
})
void shouldConvertToUpperCase(String input, String expected) {
assertThat(StringUtils.toUpperCase(input)).isEqualTo(expected);
}
```
## CsvSource - Email Validation
```java
@ParameterizedTest
@CsvSource({
"user@example.com, true",
"test@domain.org, true",
"invalid-email, false",
'", false',
"no-at-sign.com, false"
})
void shouldValidateEmailsCorrectly(String email, boolean expected) {
assertThat(ValidatorUtils.isValidEmail(email)).isEqualTo(expected);
}
```
## MethodSource - Complex Objects
```java
static Stream<Arguments> stringTransformationCases() {
return Stream.of(
Arguments.of("hello", "hello-world", "hello-world"),
Arguments.of("Hello World", "hello_world", "hello_world"),
Arguments.of("Test@123", "test123", "test123")
);
}
@ParameterizedTest
@MethodSource("stringTransformationCases")
void shouldTransformStringsCorrectly(String input, String separator, String expected) {
assertThat(StringUtils.toSlug(input, separator)).isEqualTo(expected);
}
```
## Null and Empty Sources
```java
@ParameterizedTest
@NullSource
@EmptySource
void shouldHandleNullAndEmpty(String input) {
assertThat(StringUtils.isBlank(input)).isTrue();
}
@ParameterizedTest
@NullAndEmptySource
void shouldHandleNullEmptyAndBlank(String input) {
assertThat(StringUtils.isBlank(input)).isTrue();
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |