Skip to content

ScalaTest discovery should ignore inner classes #7094

@charpov

Description

@charpov

I'm testing extensions to ScalaTest (using ScalaTest) with suites such as:

class AssertionsTests extends AnyFunSuite:
   test("assertExpr"):
      class Tests extends AnyFunSuite:
         test("success"):
            assertExpr(Seq(1, 2)):
               List(1) ::: List(2)
         test("failed"):
            assertExpr(42, ": not good"):
               40 + 1
      end Tests

      val suite = Tests()
      assert(suite.run(Some("success"), silent).succeeds())
      assert(!suite.run(Some("failed"), Args(R)).succeeds())
      R.lastEvent match
         case Some(ev: TestFailed) => assert(ev.message == "Expected 41, but got 42 : not good")
         case other                => fail(s"unexpected: $other ")

The Mill task test runs AssertionsTests, as it should, but also the inner class Tests (and counts the test "failed" as a failure).
Adding the setting def discoverTestsWithZinc = true solves the problem, but I think inner classes should always be ignored during discovery.
(Maybe it's a ScalaTest (or sbt) issue, but I find it interesting that discoverTestsWithZinc has an impact.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions