14
votes

I can run:

  1. a specific scala test
    • either by right clicking on the test and choose run
    • or if I have run it once previously, by selecting the test in run menu > run...
  2. I can run all junit tests by making a new run/debug configuration > + > junit > test kind = all in package > search for tests = in whole project
  3. I can run all scalatest (or junit) of one sub-project: right click on the project > run > scalatest in [module name]

But if I do the same as (2) with a scala test (+ > scala test > test kind...) the first test fails very strangely (it seems an object is not instantiated) while the same test pass if I run it using (1) or (3)

Config:

  • sbt with multiple subproject
  • intellij CE 15.0.2
  • scala plugin 2.1.0
  • scala 2.10

Bonus question: how to run all tests (junit and scalatest)?

1
That's a very good question, I don't know why it was down-voted. Obviously, you can run sbt test in a terminal, but I would be interested as well to know if I can have the IntelliJ IDEA GUI run all tests at once.0__
Why the down vote? Don't be shy, explain yourselfJuh_
I can do sbt test, which is done at least by the continuous integration system. But running them in intellij has several advantages. Mainly, it can run in debug, it has a nicer display (and display time taken by each test) and it has more chance to be run by my non-IT colleagues who are not comfortable with sbt.Juh_

1 Answers

1
votes

You should be able to right click on the root directory of the project and click Run "All Tests". This recursively searches for tests in your project, and will run the tests in each module.