It seems that IDEA has special knowledge of @RunWith(Parameterized.class). If you try to run ParameterTest.test via IDEA, it uses this Gradle command:
./gradlew test --tests "junit4.ParameterTest.test[*]"
This actually works when using JUnit4, because it seems you can target individual parameterised instances. This also works:
./gradlew test --tests "junit4.ParameterTest.test[*1: test(1)=false*]"
However, if you are using vintage then all of this breaks down.
You can however target the base method, which runs all parameterisations with vintage:
./gradlew test --tests "junit4.ParameterTest.test"
Current Behavior
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [junit4.ParameterTest.test[*]](--tests filter)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
3 actionable tasks: 1 executed, 2 up-to-date
Expected Behavior
Given the following JUnit Parameterized test class:
Original issue description by @ldaley:
Current Behavior
Context
Gradle only matches against the raw method name (
test
), not against the "display name" (e.g.test[0: test(0)=true]
): https://github.com/gradle/gradle/blob/01b4d16ab8ca7669599078cf71f455b129932bbd/subprojects/testing-junit-platform/src/main/java/org/gradle/api/internal/tasks/testing/junitplatform/JUnitPlatformTestClassProcessor.java#L179To make this more consistent with JUnit 4 support, the display name should be matched against as a fallback.
Steps to Reproduce
./gradlew test --tests "junit4.ParameterTest.test[*]"
Your Environment
Build scan URL: https://scans.gradle.com/s/5seok2ygcjh2a