migrate-junit-source-to-tabletest
Skill739 starsChanged 6 days agoApache-2.0View on GitHub
Convert JUnit 5 @MethodSource/@CsvSource/@ValueSource parameterized tests to @TableTest (JDK8)
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- build-logic/AGENTS.mdAGENTS.md
- buildSrc/AGENTS.mdAGENTS.md
- build-logic/CLAUDE.mdCLAUDE.md
- buildSrc/CLAUDE.mdCLAUDE.md
- .claude/CLAUDE.mdCLAUDE.md
- apm-integrationsSkill
- clarify-java-commentsSkill
- fix-continuation-leakageSkill
- java-lintSkill
- migrate-groovy-to-javaSkill
- perf-reviewSkill
- reproduce-ci-flakinessSkill
- resolve-muzzle-ciSkill
- review-groovy-migrationSkill
- techdebtSkill
- fix-continuation-leakageSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 14 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Read all matching files up front (parallel is OK).
- Distinctive: line 11
Write each modified file once in full using Write (no incremental per-test edits).
- Distinctive: line 12
Run module tests once and verify "BUILD SUCCESSFUL".
- Distinctive: line 27
Always include a header row (parameter names).
- Distinctive: line 28
Always add a "scenario" column.
- Distinctive: line 31
Prefer single quotes for strings requiring quotes (e.g., 'a|b', '[]', '{}', ' ').
- Very specific: line 32
Use value sets ({a, b, c}) instead of matrix-style repetition when only one dimension varies across otherwise-identical rows.
- Distinctive: line 36
Remove @ParameterizedTest and @CsvSource.
- Distinctive: line 37
If delimiter is '|': rows map directly to @TableTest.
- Distinctive: line 38
If delimiter is ',' (default): replace ',' with '|' in rows.
- Very specific: line 41
Keep single-parameter tests on @ValueSource (and @NullSource when null cases are needed).
- Distinctive: line 44
Add "scenario" column using common sense for name.
- Very specific: line 54
If @TableTest is not viable for the test at all, use @MethodSource only.
- Very specific: line 61
Use @TypeConverter for symbolic constants used by migrated table rows (e.g.
- Distinctive: line 62
Prefer explicit one-case-one-return mappings.
- Very specific: line 63
Prefer shared converter utilities (e.g.
- Distinctive: line 66
If MethodSource includes a leading description string OR @ParameterizedTest(name=...) uses {0}, convert that to a scenario column and …
- Distinctive: line 69
Delete now-unused @MethodSource provider methods and unused imports.
- Very specific: line 72
Prefer combining @TableTest + @MethodSource on one @ParameterizedTest when only some cases are complex.
- Distinctive: line 74
Do NOT convert when:
- Very specific: line 79
If BUILD FAILED: cat path/to/module/build/test-results/test/TEST-*.xml
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Goal: Migrate JUnit 5 parameterized tests using @MethodSource/@CsvSource/@ValueSource to @TableTest with minimal churn and passing tests.
Process (do in this order):
- Locate targets via Grep (no agent subprocess). Search for: "@ParameterizedTest", "@MethodSource", "@CsvSource", "@ValueSource".
- Read all matching files up front (parallel is OK).
- Convert eligible tests to @TableTest.
- Write each modified file once in full using Write (no incremental per-test edits).
- Run module tests once and verify "BUILD SUCCESSFUL". If failed, inspect JUnit XML report.
Import: import org.tabletest.junit.TableTest;
JDK 8 rules:
- No text blocks.
- @TableTest must use String[] annotation array syntax:
@TableTest({ "a | b", "1 | 2" })
Table formatting rules (mandatory):
- Always include a header row (parameter names).
- Always add a "scenario" column; using common sense for naming; scenario is NOT a method parameter.
- Use '|' as delimiter.
- Align columns with spaces so pipes line up vertically.
- Prefer single quotes for strings requiring quotes (e.g., 'a|b', '[]', '{}', ' ').
- Use value sets (
{a, b, c}) instead of matrix-style repetition when only one dimension varies across otherwise-identical rows.
Conversions: A) @CsvSource
- Remove @ParameterizedTest and @CsvSource.
- If delimiter is '|': rows map directly to @TableTest.
- If delimiter is ',' (default): replace ',' with '|' in rows.
B) @ValueSource
- Keep single-parameter tests on
@ValueSource(and@NullSourcewhen null cases are needed). - Otherwise convert to @TableTest with header from parameter name.
- Each value becomes one row.
- Add "scenario" column using common sense for name.
C) @MethodSource (convert only if values are representable as strings)
- Convert when argument values are primitives, strings, enums, booleans, nulls, and simple collection literals supported by TableTest:
- Array: [a, b, ...]
- List: [a, b, ...]
- Set: {a, b, ...}
- Map: [k: v, ...]
@TableTestand@MethodSourcemay be combined on the same@ParameterizedTestwhen most cases are tabular but a few cases require programmatic setup.- In combined mode, keep table-friendly cases in
@TableTest, and put only non-tabular/complex cases in@MethodSource. - If
@TableTestis not viable for the test at all, use@MethodSourceonly. - For
@MethodSource, name the arguments method<testMethodName>Arguments(camelCase, e.g.testMethodArguments) and returnStream<Arguments>usingStream.of(...)andarguments(...)with static import. - Blank cell = null (non-primitive).
- '' = empty string.
- For String params that start with '[' or '{', quote to avoid collection parsing (prefer '[]'/'{}').
D) @TypeConverter
- Use
@TypeConverterfor symbolic constants used by migrated table rows (e.g.Long.MAX_VALUE,DDSpanId.MAX). - Prefer explicit one-case-one-return mappings.
- Prefer shared converter utilities (e.g. in
utils/test-utils) when reuse across modules is likely.
Scenario handling:
- If MethodSource includes a leading description string OR @ParameterizedTest(name=...) uses {0}, convert that to a scenario column and remove that parameter from method signature.
Cleanup:
- Delete now-unused @MethodSource provider methods and unused imports.
Mixed eligibility:
- Prefer combining
@TableTest+@MethodSourceon one@ParameterizedTestwhen only some cases are complex.
Do NOT convert when:
- Most rows require complex builders/mocks.
Test command (exact): ./gradlew :path:to:module:test --rerun-tasks 2>&1 | tail -20
- If BUILD FAILED: cat path/to/module/build/test-results/test/TEST-*.xml
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

