Running unittest Tests from the Command Line

Index of All Documentation » Wing Pro Reference Manual » Unit Testing »

Wing's test runner for the unittest testing framework can be run from the command line, in order to store results in an XML file that can be loaded into Wing later using Load Test Results in the Testing menu. The test runner is src/testing/runners/ within the Install Directory listed in Wing's About box. It should be started as in the following example:

/path/to/python /path/to/wing/src/testing/runners/ [options] -q testModule.className.testName

Replace /path/to/python with the Python that should be used to run the tests, /path/to/wing with the installation directory for Wing, [options] with any of the command line options listed below, and testModule.className.testName with the real test specification.

In the test specification, testModule is the module name (without .py), className is the test class name, and testName is the name of the test method to run. To run all tests in a class, omit testName. To run all tests in a module, also omit className.

Command Line Options

--directory=<dirname> runs the tests in the given directory. When omitted, the tests are run in the current directory, inherited from the command line.

--output-file=<filename> writes results to the selected file. When omitted, results are written to stdout.

--append-to-file appends results to the file selected with the --output-file option, rather than truncating the file.

--one-module-per-process runs 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> runs tests in each filename matching the given pattern. This option may be repeated multiple times with different wildcards. This option also turns on the --one-module-per-process option.

Notes: Only the unittest test runner supports running from the command line. The other test runners cannot be used in this way. Also, running tests from the command line will not collect and update code coverage data.