Return to Snippet

Revision: 65141
at October 30, 2013 04:52 by tedg


Initial Code
package scalaunittest

import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith

@RunWith(classOf[JUnitRunner])	// Run As | JUnit Test
class ListSuite extends FunSuite {
	test("list length") {
	    val ls = List(2, 3, 4)
	    assert(ls.length == 3)
	}
}

Initial URL


Initial Description
This is a minimum scalatest suite that we can run inside Eclipse.

One is supposed to be able to run JUnit tests in Eclipse by right clicking the test class and select, from context menu, Run As | JUnit Test.  However, if a scalatest is added without the @RunWith(classOf[JUnitRunner]), the Eclipse context menu item Run As | JUnit Test is not available. The only menu item under Run As is Run Configurations .... 

Adding the @RunWith(classOf[JUnitRunner]) triggers Eclipse to add two menu item, JUnit Test, and Scala JUnit Test to be added under Run As on the context menu. Removing the annotation, will only trigger Eclipse to remove the JUnit Test item, with the Scala JUnit Test item remained. It looks like a bug. (It is about Scala IDE 3.0.1)

Initial Title
Running scalatest tests in Eclipse

Initial Tags


Initial Language
Scala