From c81b14ea942cf211e7c49789f9bb5697466dfbdb Mon Sep 17 00:00:00 2001 From: Andrea Marziali Date: Wed, 23 Sep 2026 17:19:12 +0200 Subject: [PATCH 1/2] Promote TableTest as default parameterized for Junit testing --- AGENTS.md | 2 ++ docs/how_to_test.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 9aa2409f4e8..fc0c5f97b91 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,7 @@ docs/ Developer documentation (see below) | Adding a new instrumentation | [docs/add_new_instrumentation.md](docs/add_new_instrumentation.md) | | Adding a new configuration | [docs/add_new_configurations.md](docs/add_new_configurations.md) | | Testing guide (6 test types) | [docs/how_to_test.md](docs/how_to_test.md) | +| Writing JUnit tests | [docs/how_to_test_with_junit.md](docs/how_to_test_with_junit.md) | | Writing a smoke test | [docs/how_to_smoke_test.md](docs/how_to_smoke_test.md) | | Working with Gradle | [docs/how_to_work_with_gradle.md](docs/how_to_work_with_gradle.md) | | Bootstrap/premain constraints | [docs/bootstrap_design_guidelines.md](docs/bootstrap_design_guidelines.md) | @@ -63,6 +64,7 @@ docs/ Developer documentation (see below) - **Instrumentation layout**: `dd-java-agent/instrumentation/{framework}/{framework}-{minVersion}/` - **Instrumentation pattern**: Type matching → Method matching → Advice class (bytecode advice, not AOP) - **Test frameworks**: Always use JUnit 5 for unit tests. Only use Groovy / Spock tests for instrumentation and smoke tests. +- **Parameterized tests**: Prefer `@TableTest` for multi-column literal data, with named scenarios and aligned columns. Use `@MethodSource` for cases requiring objects, builders, or mocks. See [the JUnit testing guide](docs/how_to_test_with_junit.md#parameterized-tests). - **Forked tests**: Use `ForkedTest` suffix when tests need a separate JVM - **Flaky tests**: Annotate with `@Flaky` — they are skipped in CI by default diff --git a/docs/how_to_test.md b/docs/how_to_test.md index c0eb4b5288c..add36a98f9d 100644 --- a/docs/how_to_test.md +++ b/docs/how_to_test.md @@ -1,5 +1,8 @@ # How to Test +For JUnit test authoring, see the [JUnit testing guide](how_to_test_with_junit.md). +Prefer `@TableTest` for parameterized tests with multi-column literal data; use `@MethodSource` when cases require objects, builders, or mocks. + ## The Different Types of Tests The project leverages different types of tests: From c974c06b80b01767f46b8cd3924c02580ad0fbfc Mon Sep 17 00:00:00 2001 From: Andrea Marziali Date: Wed, 23 Sep 2026 17:28:03 +0200 Subject: [PATCH 2/2] suggestion --- AGENTS.md | 2 +- docs/how_to_test.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fc0c5f97b91..95831148819 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,7 +64,7 @@ docs/ Developer documentation (see below) - **Instrumentation layout**: `dd-java-agent/instrumentation/{framework}/{framework}-{minVersion}/` - **Instrumentation pattern**: Type matching → Method matching → Advice class (bytecode advice, not AOP) - **Test frameworks**: Always use JUnit 5 for unit tests. Only use Groovy / Spock tests for instrumentation and smoke tests. -- **Parameterized tests**: Prefer `@TableTest` for multi-column literal data, with named scenarios and aligned columns. Use `@MethodSource` for cases requiring objects, builders, or mocks. See [the JUnit testing guide](docs/how_to_test_with_junit.md#parameterized-tests). +- **Parameterized tests**: Prefer `@TableTest` for multi-column literal data, with named scenarios and aligned columns. Prefer a simple `@TypeConverter` over switching to `@MethodSource` when it can turn table values into the required arguments. Use `@MethodSource` for cases requiring complex object construction, builders, or mocks. See [the JUnit testing guide](docs/how_to_test_with_junit.md#parameterized-tests). - **Forked tests**: Use `ForkedTest` suffix when tests need a separate JVM - **Flaky tests**: Annotate with `@Flaky` — they are skipped in CI by default diff --git a/docs/how_to_test.md b/docs/how_to_test.md index add36a98f9d..a0bcefdb368 100644 --- a/docs/how_to_test.md +++ b/docs/how_to_test.md @@ -1,7 +1,7 @@ # How to Test For JUnit test authoring, see the [JUnit testing guide](how_to_test_with_junit.md). -Prefer `@TableTest` for parameterized tests with multi-column literal data; use `@MethodSource` when cases require objects, builders, or mocks. +Prefer `@TableTest` for parameterized tests with multi-column literal data. When a simple `@TypeConverter` can turn table values into the required arguments, prefer it over switching to `@MethodSource`. Use `@MethodSource` for cases requiring complex object construction, builders, or mocks. ## The Different Types of Tests