Skip to content

Defective registration of nested test suites #26

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

Open
tribbloid opened this issue May 1, 2025 · 1 comment
Open

Defective registration of nested test suites #26

tribbloid opened this issue May 1, 2025 · 1 comment

Comments

@tribbloid
Copy link

tribbloid commented May 1, 2025

Here is a short example when being used with Gradle (latest version):

package com.tribbloids.spookystuff.spike

import org.scalatest.Suite
import org.scalatest.funspec.AnyFunSpec

class NestedTestsSpike extends AnyFunSpec {

  import NestedTestsSpike.*

  override def nestedSuites: IndexedSeq[Suite] = IndexedSeq(
    N1,
    N2
  )

  it("c") {}
}

object NestedTestsSpike {

  class Nested extends AnyFunSpec {

    it("a") {}
    it("b") {}
  }

  object N1 extends Nested
  object N2 extends Nested

}

upon test execution:

Task :module:sanity:test

com.tribbloids.spookystuff.spike.NestedTestsSpike$N1$ > a PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike$N1$ > b PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike$N2$ > a PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike$N2$ > b PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike$Nested > a PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike$Nested > b PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike > a PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike > b PASSED

com.tribbloids.spookystuff.spike.NestedTestsSpike > c PASSED

BUILD SUCCESSFUL in 2s
15 actionable tasks: 1 executed, 14 up-to-date

there are plenty of test cases with unknown origin (highlight in bold text)

where did they come from?

@tribbloid
Copy link
Author

I'm kind of understanding the pattern here ... the following code will behave properly, but it is nevertheless different from native scalatest runner:

package com.tribbloids.spookystuff.spike

import org.scalatest.Suite
import org.scalatest.funspec.AnyFunSpec

class NestedTestsSpike extends AnyFunSpec {

  it("c") {}
}

object NestedTestsSpike {

  class Nested extends AnyFunSpec {

    it("a") {}
    it("b") {}
  }

  class N1 extends Nested
  class N2 extends Nested
}

it appears that the JUnit 5 runner will treat every object as a package and try to discover all the test suite within (both classes & objects), but the nestedSuites cases will be inserted into the enclosing suite without adding any qualifier, causing multiple nested suites to have conflicting names

I'll see if it can be traced in debugging the plugin, maybe it's an easy fix

tribbloid added a commit to tribbloid/scalatestplus-junit5 that referenced this issue May 7, 2025
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

No branches or pull requests

1 participant