I use scala-cli
and scalatest-funsuite
. Here is the snippet
//> using scala 3.3.3
//> using test.dep org.scalatest::scalatest-funsuite:3.2.19
//> using test.dep org.scalatestplus::scalacheck-1-18::3.2.19.0
import org.scalatest.funsuite.*
// import org.scalatestplus.scalacheck.*
class HelloScalatestSuite extends AnyFunSuite {
test("hello() must return hello when no args "){
assertResult(20)(1 + 1)
}
}
Upon scala-cli test .
, the test must fail but the Test itself is not recognized. Commenting out //> using test.dep org.scalatestplus::scalacheck-1-18::3.2.19.0
runs the test as expected. The same set of dependencies (scalacheck + scalatest works fine with sbt.
What am I missing with scala-cli settings ?
I think the problem is related to there being 2 test libraries imported at once. Not sure if ScalaCheck counts as one, but it appearing to cause the issue suggests something like that... the auto-detection scans the classpath I think, so something in there must be causing confusion.
It started working when I explicitly specified ScalaTest's Framework implementation to scala-cli:
//> using testFramework org.scalatest.tools.Framework
The fix would probably work in principle for any combination of test frameworks that end up not being detected.
I found this info by noticing that the scala-cli docs mention something similar for Weaver (using testFramework
), recognizing the sbt Framework interface from that one time I read about how to implement your own Scala test framework, and searching for it in ScalaTest's API docs.