Skip to content

Commit d48cfca

Browse files
committed
Merge branch 'feature-dynamic-test-name-fix' of https://github.com/scalatest/scalatestplus-junit5
2 parents 8a32e1b + f75561e commit d48cfca

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package co.helmethair.scalatest.example
2+
3+
import org.scalatest.funsuite.AnyFunSuiteLike
4+
5+
class DynamicTest extends AnyFunSuiteLike {
6+
7+
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
8+
}
9+
10+
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
11+
}
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package co.helmethair.scalatest.example
2+
3+
import org.scalatest.funsuite.AnyFunSuiteLike
4+
5+
class DynamicTest extends AnyFunSuiteLike {
6+
7+
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
8+
}
9+
10+
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
11+
}
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package co.helmethair.scalatest.example
2+
3+
import org.scalatest.funsuite.AnyFunSuiteLike
4+
5+
class DynamicTest extends AnyFunSuiteLike {
6+
7+
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
8+
}
9+
10+
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
11+
}
12+
13+
}

src/main/scala/org/scalatestplus/junit5/ScalaTestEngine.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ class ScalaTestEngine extends org.junit.platform.engine.TestEngine {
263263
val children = clzDesc.getChildren.asScala
264264

265265
val filter =
266-
if (children.isEmpty)
266+
if (children.isEmpty ||
267+
suiteToRun.testNames.size == children.size
268+
) // When testNames size is same as children size, it means all tests are selected, so no need to apply filter, this solves the issue of dynamic test names when running suite.
267269
Filter()
268270
else {
269271
val SelectedTag = "Selected"

0 commit comments

Comments
 (0)