Steps to reproduce
class Tests {
@BeforeEach
fun setUp(info: TestInfo) {
System.out.println(info.displayName)
}
@MethodSource("methodSource")
@ParameterizedTest(name = "{displayName} - {0}") // BUG
fun `displayName'Zero`(param: String) {
// displayNameZero(String) - {0}
// displayNameZero(String) - {0}
}
@MethodSource("methodSource")
@ParameterizedTest(name = "{0} - {displayName}")
fun `zero'DisplayName`(param: String) {
// foo - zeroDisplayName(String)
// bar - zeroDisplayName(String)
}
@MethodSource("methodSource")
@ParameterizedTest(name = "{displayName} - {0}")
fun displayNameZero(param: String) {
// displayNameZero(String) - foo
// displayNameZero(String) - bar
}
@MethodSource("methodSource")
@ParameterizedTest(name = "{0} - {displayName}")
fun zeroDisplayName(param: String) {
// foo - zeroDisplayName(String)
// bar - zeroDisplayName(String)
}
companion object {
@JvmStatic
private fun methodSource(): Array<String> =
arrayOf(
"foo",
"bar"
)
}
}
- Clone https://github.com/TWiStErRob/repros/tree/main/junit/jupiter-params-displayName-vs-apostrophe
gradlew test
- Review report at
build/reports/tests/test/index.html
Note: the repro project is a bit more complex than the above:
TestK is a pure Kotlin version
TestJ is a pure Java version
Test is the problematic version with Kotlin apostrophes.
I made them really similar so it's easy to compare their outputs.
Expected
No {0} anywhere.
It works correctly without apostrophes:
build/reports/tests/test/classes/com.example.MyTestK.html
Actual
When the method name contains ', the {0} is not substituted.
It fails formatting the name when apostrophes are added:
build/reports/tests/test/classes/com.example.MyTest.html
Context
- Used versions (Jupiter/Vintage/Platform): 5.9.2
- Build Tool/IDE: Gradle / IDEA, but likely irrelevant.
Deliverables
I think the problem might be around ParameterizedTestNameFormatter, but didn't debug it.
Steps to reproduce
gradlew testbuild/reports/tests/test/index.htmlNote: the repro project is a bit more complex than the above:
TestKis a pure Kotlin versionTestJis a pure Java versionTestis the problematic version with Kotlin apostrophes.I made them really similar so it's easy to compare their outputs.
Expected
No
{0}anywhere.It works correctly without apostrophes:
build/reports/tests/test/classes/com.example.MyTestK.htmlActual
When the method name contains
', the{0}is not substituted.It fails formatting the name when apostrophes are added:
build/reports/tests/test/classes/com.example.MyTest.htmlContext
Deliverables
I think the problem might be around
ParameterizedTestNameFormatter, but didn't debug it.