migrate-junit-source-to-tabletest

Converts JUnit 5 parameterized tests to @TableTest format for JDK 8 projects.

735|355|Updated Apr 24, 2017
One-click install
npx skills add https://github.com/DataDog/dd-trace-java --skill migrate-junit-source-to-tabletest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-junit-source-to-tabletest
Source: https://github.com/DataDog/dd-trace-java/tree/main/.agents/skills/migrate-junit-source-to-tabletest
Command: npx skills add https://github.com/DataDog/dd-trace-java --skill migrate-junit-source-to-tabletest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrating JUnit 5 parameterized tests written with @MethodSource, @CsvSource, or @ValueSource to the @TableTest format is repetitive and error-prone, especially under JDK 8 constraints where text blocks are unavailable and table syntax must follow strict formatting rules.

Core Features & Use Cases

  • Automated Conversion: Transforms @CsvSource, @ValueSource, and @MethodSource parameterized tests into @TableTest with aligned pipe-delimited tables, header rows, and scenario columns.
  • JDK 8 Compliance: Enforces String[] annotation array syntax, single-quote string handling, and value-set notation instead of matrix repetition.
  • Mixed Eligibility Handling: Combines @TableTest with @MethodSource on one @ParameterizedTest when only some cases are tabular, and uses @TypeConverter for symbolic constants.
  • Use Case: A developer modernizing a Java test suite can convert dozens of @CsvSource tests into readable @TableTest tables, then run the module's Gradle tests to verify BUILD SUCCESSFUL.

Quick Start

Convert all @MethodSource, @CsvSource, and @ValueSource parameterized tests in this module to @TableTest and run the module tests to verify the build passes.

Frequently Asked Questions about migrate-junit-source-to-tabletest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert JUnit 5 @CsvSource tests to @TableTest?

Remove @ParameterizedTest and @CsvSource, then map each row into a @TableTest String[] array using '|' as the delimiter. Add a header row with parameter names and a scenario column, aligning columns so pipes line up vertically.

How to migrate @MethodSource parameterized tests to table-driven tests?

Convert @MethodSource to @TableTest when argument values are primitives, strings, enums, booleans, nulls, or simple collection literals. Complex cases can stay in @MethodSource combined with @TableTest on the same @ParameterizedTest, with the provider method named <testMethodName>Arguments returning Stream<Arguments>.

Does @TableTest work on JDK 8 without text blocks?

Yes, @TableTest works on JDK 8 by using the String[] annotation array syntax instead of text blocks. Each table row is a separate string element in the annotation array, with '|' delimiters and aligned columns.

When should I not convert a parameterized test to @TableTest?

Do not convert when most rows require complex builders or mocks that cannot be represented as strings. Single-parameter @ValueSource tests should also stay as-is, and @NullSource should be kept when null cases are needed.

How do I handle constants like Long.MAX_VALUE in @TableTest rows?

Use @TypeConverter for symbolic constants referenced by migrated table rows, such as Long.MAX_VALUE or DDSpanId.MAX. Prefer explicit one-case-one-return mappings and shared converter utilities when reuse across modules is likely.

Why did my Gradle test build fail after migrating to @TableTest?

Run the module test command and check the JUnit XML report at the module's build/test-results/test/TEST-*.xml path if the build fails. Common causes include unquoted strings starting with '[' or '{', missing scenario columns, or leftover unused imports.