scalaeclipse-plugintestngscala-idetypesafe-stack

How to run Scala tests with the TestNG plugin in Scala IDE / Eclipse?


I am using the Typesafe Scala IDE 3.0.0 together with the TestNG 6.8.1 plugin. What I really miss is the possibility to right-click on a Scala file, then select "Run As" and "TestNG Test" to launch the tests in the IDE. This feature works for Java-based TestNG tests, but not for tests written in Scala.

Silly example:

import org.testng.annotations.Test
import org.testng.Assert

class MyTest {
  @Test
  def doSomeTesting() {
    Assert.assertEquals(true, false)
  }
}

I am also using Maven and the Surefire plugin, and the test is picked up and executed nicely when I run "mvn test". So I assume the Eclipse plugin does not recognize that the Scala file is a TestNG test. Is there a way to make the TestNG plugin work with Scala tests? Any working configuration could help.


Solution

  • I had the same problem you described. Instead of the Run menu, you should use the related shortcut. That is to say āŒ˜ + āŒ„ + X then N for Mac users, Ctrl + Alt + X then N for the others.

    Hope that helps.