junit module

junit module provides a set of high level functions on top of JUnit API.

runTextUI ( ( File | String ) directoryOrFile ) or
( pnuts.lang.Package pkg ) or
( junit.framework.TestSuite testSuite )
runSwingUI ( ( File | String ) directoryOrFile ) or
( pnuts.lang.Package pkg )
runAWTUI ( ( File | String ) directoryOrFile ) or
( pnuts.lang.Package pkg )

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 ( ( File | String ) directoryOrFile ) or
( pnuts.lang.Package pkg )
( junit.framework.TestSuite testSuite )

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 ( ( File | String ) fileOrDirectory )

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)
assertTrue ( { message , } arg )
assertFalse ( { message , } arg )
assertEquals ( { message , } expected, actual {, delta } )
assertNull ( { message , } arg )
assertNotNull ( { message , } arg )
assertSame ( { message , } expected, actual )
assertNotSame ( { message , } expected, actual )
fail ( { message } )

These functions may throw junit.framwork.AssertionFailedError if an unexpected value is given.

function test1(){
  obj = MyClass::booleanMethod()
  assertTrue(obj)
}