Running ScalaTest Tests Under IntelliJ IDEA
I had lots of difficulties running my tests under IDEA. The exact error message was:
Error running All Tests:
Not found suite class.
Where All Tests was the name of my Run configuration.
I finally ended up with the right incantations. In my POM, I have the following:
1 <dependencies>
2 <dependency>
3 <groupId>junit</groupId>
4 <artifactId>junit</artifactId>
5 <version>4.8.1</version>
6 <scope>test</scope>
7 </dependency>
8 <dependency>
9 <groupId>org.scalatest</groupId>
10 <artifactId>scalatest_2.9.0-1</artifactId>
11 <version>1.6.1</version>
12 </dependency>
13 <dependency>
14 <groupId>org.mockito</groupId>
15 <artifactId>mockito-core</artifactId>
16 <version>1.8.1</version>
17 <scope>test</scope>
18 </dependency>
19 </dependencies>
Then, I had to extend org.scalatest.junit.JUnitSuite for my test classes, like this:
1 import JUnitSuite
2 import org.junit.Test
3
4 class GivenAnEmptyQueue extends JUnitSuite {
5 @Test def thenItShouldNotHaveAnyElements() {
6 assert(new Queue.empty)
7 }
8 }
Finally, I had to verify that both the JUnit and Scala plugins were enabled and at their latest versions in the IDE itself. After that, I was able to run my tests from within the IDE.