Running Tests

You can run a test file just as you run other files in the Workbench. You select the test file, right-click, and choose Run As or Debug As and then Mathematica. This is described in the launching section. If you need to initialize before the tests are run, this can be done in the normal way.

One difference from running a notebook .nb file is that test files run the Mathematica kernel directly. If you want tests that use the front end, this can be done in the standard fashion, using the Mathematica function UseFrontEnd.

When the test has completed, a test output report is generated. A typical result is shown below.

MUnit Tester

The red bar at the top of this report is a quick indication that you did not have a 100% pass rate. It also tells you that one test passed and two tests failed. Underneath is a progress bar that shows progress in the test file as it is executed.

If you click the test in the test report, this jumps to the test in its source file. Also, if you select a failed test you can see the expected and actual output. This helps to track down the problem.

Navigating in Test Files

The Workbench provides a number of useful navigation features between the test file and the test report. For example, you move from the file to its location in the report using the Show In feature. This is very useful to find out if a particular test passed or failed. After carrying out a test run, select something in a test, right-click, and bring up the context menu. Under Show In you can choose MUnit, as shown below.

MUnit Tester

Child Test Files

If you launch a test file from within another file, using either Get or TestRun, then the results will be collected in the report along with tests in the parent file.