Skip to content

detect custom Gradle test source sets in test import options#1660

Open
Develop-KIM wants to merge 1 commit into
TNG:mainfrom
Develop-KIM:fix/gradle-test-pattern-custom-source-sets
Open

detect custom Gradle test source sets in test import options#1660
Develop-KIM wants to merge 1 commit into
TNG:mainfrom
Develop-KIM:fix/gradle-test-pattern-custom-source-sets

Conversation

@Develop-KIM

Copy link
Copy Markdown

What & why

Fixes #1578. ImportOption.DoNotIncludeTests and OnlyIncludeTests did not recognize tests in custom Gradle source sets (e.g. integrationTest, functionalTest, e2eTest), because GRADLE_TEST_PATTERN only matched the standard lowercase test folder. Custom test classes were therefore treated as production code — not excluded by DoNotIncludeTests, and not included by OnlyIncludeTests.

Change

  • Broaden GRADLE_TEST_PATTERN from .*/build/classes/([^/]+/)?test/.* to .*/build/classes/([^/]+/)?(test|[^/]+Test)s?/.*, so it also matches source-set output folders that follow the Gradle ...Test naming convention (plus the plural tests).
  • Requiring the camelCase capital Test boundary keeps main excluded, preserves the separately handled testFixtures folder (DoNotIncludeGradleTestFixtures), and avoids false positives such as latest.
  • Update the DoNotIncludeTests Javadoc accordingly.
  • Add ImportOptionsTest data points for integrationTest, functionalTest, e2eTest, tests, and a testFixtures → main regression guard.

Verification

./gradlew :archunit:test --tests "*ImportOptionsTest" → 92 tests, 0 failures (the new source-set folders resolve as test locations; testFixtures/main stay non-test). :archunit:spotlessCheck passes.


This change was prepared with AI assistance (Claude); I have reviewed and verified it and take responsibility for the contribution.

`ImportOption.DoNotIncludeTests` and `OnlyIncludeTests` relied on
`GRADLE_TEST_PATTERN` matching only the standard `test` source set
(`.../build/classes/[lang]/test/...`). Classes compiled from custom
Gradle test source sets such as `integrationTest`, `functionalTest` or
`e2eTest` were treated as production code, so they were not excluded by
`DoNotIncludeTests` (and not included by `OnlyIncludeTests`).

Broaden the pattern to also match source set folders following the
Gradle `...Test` naming convention (plus the plural `tests`), while
still ignoring `main` and the separately handled `testFixtures` folder,
and without matching unrelated names such as `latest`.

Resolves: TNG#1578

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Develop-KIM <kimdonghwan913@gmail.com>
@Develop-KIM Develop-KIM force-pushed the fix/gradle-test-pattern-custom-source-sets branch from 1039fdf to 8f4183c Compare July 9, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportOption.DoNotIncludeTests and ImportOption.OnlyIncludeTests don't detect tests in custom Gradle source sets

1 participant