- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Configuring Eclipse JUnit 4 runner for Scala tests
Thu, 2009-05-14, 18:40
Hello there:
I recently managed to get a dev environment working using the following
combination:
Scala Eclipse plug-in
M2 maven plug-in
Subversive Eclipse plug-in
I am using Eclipse classic 3.4.1 with Scala plugin 2.7.4.final.
I've created a simple, multi-module maven project; one of the child modules
is a Scala project generated from the command line via:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate
and selecting option “30: internal -> scala-archetype-simple (A simple scala
project)”
Everything works pretty well in Eclipse (ie I can compile and run Scala
apps) and the maven build succeeds as well (all tests are executed).
The maven archetype generated the following JUnit test for me:
package org.foo.bar.baz
import org.junit._
import Assert._
@Test
class AppTest {
@Test
def testOK() = assertTrue(true)
// @Test
// def testKO() = assertTrue(false)
}
which runs fine from the maven command line. However, when I select the
test in Eclipse, I don't get the “Run as → Junit Test” option from the
context menu.
I've followed the steps suggested in:
http://www.scala-lang.org/node/363
and managed to run the test by manually creating a “Run Configuration” and
explicilty configuring the test under the option “Run a single test”,
supplying as the test class “org.foo.bar.baz.AppTest”. I still however,
don't get a “Run as → Junit Test” context menu.
The other option in the “Run Configuration” dialog, “Run all test in the
selected project, package, or source folder” does not seem to work (ie the
test is not picked up).
How would I configure a whole bunch of JUnit tests? Will I need to manually
create all these entries?
Does anyone know how can I get my JUnit context menu enabled for the test
above?
Thanks in advance for any help.