Running unittest Tests From the Command Line
Wing's unittest test runner can be run from the command line and store results in an XML file that can be loaded into Wing via the Load Test Results item in the Testing menu. The test runner script is src/testing/runners/run_unittest_xml.py within the install directory listed in Wing's About box. It should be run with the Python interpreter that should be used for the selected tests as follows:
/path/to/python /path/to/src/testing/runners/run_unittests_xml.py [options] -q testModule.className.testName
Where [options] is replaced with any of the command line options listed below and the test specification is the test specification used when running with the standard library's unittest module. The test specification above consists of testModule is the module name (without .py), className is the test class name, and testName is the name of the test to run. To run all tests in a class, omit the testName. To run all tests in a module, omit also the className.
Available command line options are:
- --directory=<dirname>: Run in the given directory. Otherwise runs in the current directory inherited from the command line.
- --output-file=<filename>: Write results to the selected file. Results are written to stdout if this option is not given.
- --append-to-file: Append results to the file selected with the --output-file= option.
- --one-module-per-process: Run each module in a separate process space to avoid unintended interactions between the tests. Tests are still run sequentially and not concurrently.
- --pattern=<glob filename pattern>: Run tests in each filename matching the given glob pattern. This option may be repeated multiple times with different glob patterns. It also turns on the --one-process-per-module option.
Note: Only the unittest test runner supports running from the command line. The other test runners cannot be used this way.