- Home
- Skills
- Giuseppe Trisciuoglio
- Developer Kit
- Unit Test Parameterized
unit-test-parameterized_skill
- Python
99
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill giuseppe-trisciuoglio/developer-kit --skill unit-test-parameterized- SKILL.md11.9 KB
Overview
This skill provides practical patterns for writing parameterized unit tests with JUnit 5 using @ParameterizedTest, @ValueSource, @CsvSource, @MethodSource, @EnumSource and custom providers. It helps run the same test logic with multiple input sets to reduce duplication and increase coverage. The guidance covers setup, common sources, display names, and edge-case strategies.
How this skill works
Add the junit-jupiter-params dependency and annotate test methods with @ParameterizedTest. Attach a data source annotation (@ValueSource, @CsvSource, @MethodSource, @EnumSource, @ArgumentsSource or @CsvFileSource) so JUnit automatically invokes the test once per data row. Use static factory methods or custom ArgumentsProvider for complex objects and names with placeholders for readable output.
When to use it
- When a method must be validated across many input values without duplicating test code
- When you need systematic boundary and edge-case coverage (including nulls and extremes)
- When validating tabular inputs or combinations of arguments
- When testing all or filtered enum values
- When building reusable, data-driven tests for business rules or validators
Best practices
- Keep each parameterized test focused on a single assertion or behavioral expectation
- Choose the simplest data source: @ValueSource for literals, @CsvSource for tabular, @MethodSource for objects
- Include boundary and invalid inputs alongside normal cases
- Use descriptive display names with placeholders (e.g. name = "{0} => expected {1}")
- Group related scenarios and prefer reusable ArgumentsProvider for complex sets
Example use cases
- Validate email or phone validators with @CsvSource rows mapping input to expected boolean
- Verify numeric math logic across positive, negative and extreme integers with @ValueSource or @MethodSource
- Run the same business rule for every enum state using @EnumSource
- Supply complex DTOs or many arguments using a static factory method and @MethodSource
- Load test cases from CSV files with @CsvFileSource for large datasets
FAQ
Ensure the number and types of parameters in the method signature match the values provided by the source. Use Arguments.of(...) in MethodSource to align types.
Can I include null values in @CsvSource or @ValueSource?
ValueSource does not support null or complex objects. Use @CsvSource with special syntax (empty token or explicit markers) or @MethodSource to produce nulls and objects.