-
Notifications
You must be signed in to change notification settings - Fork 21
Description
I have a simple Scala project (no external dependencies except for Scala 2.7.2.final JUnit 4.4)
source folders:
Source/Scala output to target/classes
UnitTest/Source/Scala output to target/test-classes
After creating a new test class named com/mypackage/TestMain
with JUnit 4 annotations
import org.junit.Test
import org.junit.Assert.assertTrue
@Test
class TestMain {
@Test
def runSamples : Unit = {
assertTrue(true)
}
}
the plugin compiles this file correctly
(I can see the .class file in the Navigator view of my target/test-classes folder) but I cannot run it as a JUnit test.
Eclipse shows a dialog:
No tests found with test runner 'JUnit 4'
Some discussion of this problem appeared on the mailing list;
see http://www.nabble.com/How-to-use-junit-4-with-scala-under-eclipse-3.3--td18434072.html
One workaround is to add the bin directory as a source folder.
Eclipse does not let me do this via the UI; I get an error such as
Source folder '!UnitTest/Source/Scala' in project 'sas.acl.al.scala' cannot output to distinct source folder 'target/test-classes'
I can close the project and add the directory by editing the .classpath file outside of Eclipse, and sometimes this problem goes away, but each time I add a new unit test, I have to close the project (which closes my open files) and reopen it. Even then, sometimes Eclipse loses track of the unit tests and won't run them.
I use JUnit instead of !ScalaTest, Specs etc. because our larger development process uses JUnit and Maven to build projects and run unit tests and generate reports, and also I prefer the ability to run unit tests from Eclipse and use the JUnit view.