Scala for NetBeans Screenshot#12: JUnit integration
There is a Scala JUnit Test template in Scala for NetBeans now, you can create Scala JUnit testing and run testing, see testing result.
Here is an example test file:
/*
* DogTest.scala
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package scalajunit
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.Assert._
class DogTest {
@Before
def setUp() = {
}
@After
def tearDown() = {
}
@Test
def testHello() = {
val dog = new Dog()
dog.talk("Mr. Foo")
assert(true)
}
@Test
def testAdding() = {
assertEquals(4, 2 + 3)
}
}
To get JUnit working, upgrade to Scala Project Module version 1.2.14, and re-create a new project for exist old project (if there has been one). Under the "Test Packages", create your testing packages, right click on package node, select create "Scala JUnit Test".
To run tests, right-click on project node, choose "Test".
And also, the beta-release is feature frozen, I'll concentrate on bug-fixes in next 1-2 weeks, and get it ready for public release as beta.
![(please configure the [header_logo] section in trac.ini)](/chrome/!97aa87b5/site/your_project_logo.png)
rss

Comments
Note that the class of the JUnit test must end in Test, at least in NetBeans 7.0.1 and Ant.
For example, there are no problems using class names DogTest?, CatTest? or VeryLongClassNameComplicatedTest?, but because of restrictions due to NetBeans (not the plugin), if you choose to use names such as TestDog?, TestComplicatedThing? or SomeExperiement? then these tests will not be run automatically when you do right click the Project node and choose Test.
Last word of warning: You cannot right-click a test file and choose 'Test File' as you can for Java projects; you MUST right-click the PROJECT node and choose Test.
Is it possible to use TestSuites??
In the same vien as the example given above, I tried:
@RunWith?(classOf[Suite]) @Suite.SuiteClasses?(Array(classOf[QuickTest?], classOf[ExhaustiveTest?])) class AllTests? {}
However, this suite did not run when I right-clicked the project node and clicked Test. (I tried renaming AllTests? -> AllTest?, but this had no effect.)