Skip to content
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

Fix Suite support #87

Merged
merged 6 commits into from
Aug 16, 2024
Merged

Fix Suite support #87

merged 6 commits into from
Aug 16, 2024

Conversation

eed3si9n
Copy link
Member

@vasilmkd
Copy link
Contributor

I understand if the original intention of the fix for @Suite was to only fix JUnit 4 suites. I only wish to provide some feedback about other cases.

The JUnit 3 TestSuite is still not fixed by this PR (I did a publishLocal). It still produces:
[error] java.lang.RuntimeException: Test class MathTest is not enclosed by MathSuite for the following test sources.

// src/test/MathTest.scala
// This is a definition of a JUnit 3 test case. Many of these test cases will be "dynamically" collected into a JUnit 3 `TestSuite` and run.

class MathTest(op1: Int, op2: Int, res: Int) extends TestCase(s"$op1 + $op2 = $res") {
  final override def runTest(): Unit = {
    assertEquals(res, op1 + op2)
  }
}
// src/test/MathSuite.scala

class MathSuite extends TestCase

object MathSuite {
  // This is essentially a Scala 2.12+ hack, where methods on the companion object produce static forwarders on the class.
  // This is the Scala equivalent of the JUnit 3 convention public static Test suite() { ... }
  def suite(): Test = {
    val s = new TestSuite("MathSuite")
    s.addTest(new MathTest(1, 2, 3))
    s.addTest(new MathTest(2, 3, 4))
    s
  }
}

@eed3si9n
Copy link
Member Author

@vasilmkd I've split the above comment into a new issue - #89

@eed3si9n eed3si9n merged commit d9537f9 into sbt:main Aug 16, 2024
5 checks passed
@eed3si9n eed3si9n deleted the wip/suite branch August 16, 2024 03:51
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

Successfully merging this pull request may close these issues.

Unable to Run Test Suite Class Not Enclosed
3 participants