junit module provides a set of high level functions on top of JUnit API.
When a pnuts.lang.Package object is given, these functions create a TestSuite object with testXXXX() methods defined in the package.
When a file or directory is given to the parameter, these functions create a TestSuite object from the functions testXXXX() in the specified script files, or the script files under the specified directory. Then it executes them using TestRunner of JUnit.
runTextUI(".")
runPnutsUI() builds a test suite in the same way as the functions above and shows the ongoing status of the test with a custom user interface.
buildTestSuite() creates and returns a junit.framework.TestSuite object from the functions testXXXX() in the specified script files, or the script files under the specified directory.
The following script illustrates how to execute a unit test without TestRunner.
import("junit.framework.*")
test = buildTestSuite(".")
result = TestResult()
test.run(result)
printAll(result.failures())
printAll(result.errors())
The code below is a simple usage of junit.extensions.RepeatedTest.
import("junit.extensions.*")
test = buildTestSuite(".")
test3 = RepeatedTest(test, 3)
runTextUI(test3)
These functions may throw junit.framwork.AssertionFailedError if an unexpected value is given.
function test1(){
obj = MyClass::booleanMethod()
assertTrue(obj)
}