I'm trying to run a scala flatspec test within Intellij IDEA (latest community build, with latest Scala plugin), but I keep getting "Empty test suite" errors.
I tried using the normal "run" menu on right click, but it does not work. I also tried creating a new ScalaTest configuration, but still the runner is not picking up the tests.
I was able to use JScalaTest with unit, but I'd really prefer to use flatspec syntax.
UPDATE: annotating the class with @RunWith(classOf[JUnitRunner])
does not help either
Thanks!
class SampleTestSpec extends FlatSpec with ShouldMatchers {
"test" should "fail" in {
"this" should equal ("that")
}
}
UPDATE: Switching from ScalaTest to Spec, solved the problem. I still prefer ScalaTest with FlatSpec, but this is good enough. Code that works:
import org.specs._
object SampleTestSpec extends Specification {
"'hello world' has 11 characters" in {
"hello world".size must be equalTo(113)
}
"'hello world' matches 'h.* w.*'" in {
"hello world" must be matching("h.* w.*")
}
}
-teo
If IntelliJ does not pick up the tests automatically, you can do the following:
In the Run Configuration, create a ScalaTest run configuration and set up its "Test kind" to "All in package" and its "Test Package" to the package that contains your tests.