Running the test suite

MAT includes a good deal of test code for the core Python library and tools. There's also some Java JUnit test code, which can be found in the lib/mat/java subdirectory in an appropriate location for building a Netbeans project. There's no Javascript test code, and no test code for the MAT UI itself. This page documents the test code for the core Python library and tools.

The test suite is known to pass on Linux/Unix platforms; it may generate a few (ignorable) errors on Windows.

Unix:

% python $MAT_PKG_HOME/test/mat_unittest.py --help

Windows:

> python.exe %MAT_PKG_HOME%\test\mat_unittest.py --help

Usage: mat_unittest.py [ --debug ] [ --quiet ] [ --verbose ] [ --tmpdir <d> ] [ --block_context_teardown ]
[ --setting <a>=<b> ]* [ --categories a,b,c... ] [ --class_name_pattern p ]
[ --test_name_pattern p ] app_dir...

Options

--debug
pass debug to unittest
--verbose
verbose execution
--tmpdir <d>
the temp directory will be created in <d> instead of the default location
--block_context_teardown
don't clean up the context at the end (so tmpdir remains)
--setting <a>=<b>
provide a setting to the test context
--categories <a,b,c...>
an optional comma-delimited list of core categories to test. If present, the system will test only files in the unittest directory named mat_<category>_unittest.py
--class_name_pattern <p>
an optional Python regular expression pattern to filter unit test class names
--test_name_pattern <p>
an optional Python regular expression pattern to filter the individual test method names

Using the test suite

The basic invocation is

% python $MAT_PKG_HOME/test/mat_unittest.py

This will run all the installed tests for the core MAT system.

If any tasks are installed, and they have a test/ subdirectory with Python files, and you pass the task directory as an argument to the test suite, those files will be run as part of the test. In order to test just the task, and ignore the core tests, use --categories "" (empty string) in your command line. The --setting option passes values to these task tests (if you have any tasks with tests in them, you may have some examples of this, but it's unlikely).

The core tests are subdivided into a number of files in the test/ subdirectory named mat_<category>_unittest.py. The --categories option allows you to select a subset of these to run. E.g., if you just want to run the tests in mat_workspace_unittest.py, call

% python $MAT_PKG_HOME/test/mat_unittest.py --categories workspace