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
To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.
Make sure you have the scala plugin for intellij. Go file>new>'project from existing source', select your project to import. Go to build. sbt and there should be a prompt to import the packages.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With