-
Notifications
You must be signed in to change notification settings - Fork 0
feat(reqstool): add build config conventions for JUnit5 parameterized test names #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ool/skills/reqstool-conventions/references/reqstool-build-config-conventions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # reqstool Build & Test Runner Configuration Conventions | ||
|
|
||
| reqstool maps `<testcase name="...">` entries in JUnit XML test reports to | ||
| `@SVCs`-annotated test methods. If a test runner writes a name that doesn't include | ||
| the method name, reqstool can't make that link. | ||
|
|
||
| This doc currently covers **Gradle + JUnit 5**. Maven Surefire is unaffected — it | ||
| always embeds the method name regardless of display-name settings. | ||
|
jimisola marked this conversation as resolved.
|
||
|
|
||
| ## Gradle + JUnit 5 Parameterized Tests | ||
|
|
||
| ### Symptom | ||
|
|
||
| Gradle's JUnit XML reporter writes parameterized `@Test` case names using the | ||
| display name, which defaults to `[N] arguments` — a format that omits the method | ||
| name. When reqstool processes the JUnit XML test results (e.g. via | ||
| `reqstool status`), this produces warnings like: | ||
|
jimisola marked this conversation as resolved.
|
||
|
|
||
| ``` | ||
| Skipping parameterized test case with display-name-only format (method name not | ||
| recoverable): '[1] ACTIVE' in <test-result-file> | ||
|
jimisola marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| and the corresponding `@SVCs` IDs are never marked as verified. | ||
|
|
||
| ### Fix | ||
|
|
||
| Configure JUnit 5 to include the method name in the display name by setting the | ||
| `junit.jupiter.params.displayname.default` system property on all test tasks | ||
| (unit, integration, e2e): | ||
|
jimisola marked this conversation as resolved.
|
||
|
|
||
| ```kotlin | ||
| // Kotlin DSL (build.gradle.kts) | ||
| tasks.withType<Test>().configureEach { | ||
| systemProperty("junit.jupiter.params.displayname.default", "{displayName}[{index}]") | ||
| } | ||
| ``` | ||
|
|
||
| ```groovy | ||
| // Groovy DSL (build.gradle) | ||
| tasks.withType(Test).configureEach { | ||
| systemProperty 'junit.jupiter.params.displayname.default', '{displayName}[{index}]' | ||
| } | ||
| ``` | ||
|
|
||
| This produces test case names like `checkStatus(StatusType)[1]` instead of | ||
| `[1] ACTIVE`, which reqstool can parse to recover the method name and link the | ||
| result to its `@SVCs` annotation. | ||
|
|
||
| > **Explicit `name=` overrides this:** tests using `@ParameterizedTest(name = "{index} ...")` | ||
| > still omit the method name, because the explicit `name` overrides the | ||
| > `systemProperty` default. Either remove the custom `name` or change it to begin | ||
| > with `{displayName}`: `@ParameterizedTest(name = "{displayName}[{index}] ...")`. | ||
|
jimisola marked this conversation as resolved.
|
||
|
|
||
| ## References | ||
|
jimisola marked this conversation as resolved.
|
||
|
|
||
| - [reqstool-java-gradle-plugin PR #63](https://github.com/reqstool/reqstool-java-gradle-plugin/pull/63) | ||
| documents this fix (open at time of writing) | ||
| - [reqstool-client PR #405](https://github.com/reqstool/reqstool-client/pull/405) — | ||
| parser-side handling for Gradle parameterized test names | ||
|
jimisola marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.