Put the your tests in a separate source folder. See this tutorial on setting up JUnit in Eclipse for more information.
Add JUnit to your project's build path. Select the project and choose "Build Path" -> "Add Libraries...". Then choose the JUnit jar.
Add the output directory of your project to your build path. See this short guide from the makers of Spec.
To get you started, here is a simple test:
package tests
import junit.framework._
import org.junit.Assert._
class FirstTest extends TestCase {
override def setUp() = {
}
override def tearDown() = {
}
def testOne() = {
assertEquals(1, 1)
}
}
2 comments:
I tried to do the same with Junit4. It works fine *however* after I restart Eclipse the runner doesn't find test methods. I need to add the output directory of my project to my build path again. Do you have the same problem? If yes, maybe you have some way to fix it?
Jau,
I tried to recreate your problem, but that doesn't seem to happen to me. I'd suggest the Scala Nabble forums or Eclipse forums. I'm definitely no Eclipse expert, but many people there are. Good luck, and let me know what you figure out so I can amend my post.
--Kevin
Post a Comment