Running Tests

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


Tests can be run and debugged from Wing in a variety of ways. The options are:

  • Run all tests in the testing tool. This is done with the Run All Tests item in the Testing menu or by selecting no tests (or all tests) in the list and pressing the Run Tests button.
  • Run only the tests in current file open in the source editor. This is done with the Run Tests in Current File item in the Testing menu.
  • Run a subset of test(s) by location of the cursor or selection in the source editor. This is done with the Run Tests at Cursor item in the Testing menu.
  • Run tests that failed the last time tests were run. This is done with the Run Failed Tests item in the Testing menu.
  • Run all tests that were run the last time tests were run. This is done with the Run Tests Again item in the Testing menu.

Test files and/or individual tests may also be selected in the Testing tool and run with the Run Tests button or using the items in the context menu (right click) on the Testing tool.

For each of these run options, there is an equivalent debug option that will run the tests in the debugger. These are in the Debug group of the Testing menu.

To stop running tests, use the Abort Running Tests item in the Testing menu or the Abort Tests item on the Testing tool.

To clear the previous test results from the Testing tool, use the Clear Results item in the right-click context menu.

Options

There are several options available for how Wing runs unit tests.

Process Model

When multiple test files are run at once, they may either be each run in a separate OS process for each file (the default), or all test files in one directory may be run in a single process. This option is set via Process Model under the Testing tab of the Project Properties dialog.

In the Per-Module model, Wing is running the equivalent of the following command line:

cd /path/to/files
python -m unittest one.py
python -m unittest two.py

In the Per-Package model, Wing is running the equivalent of:

cd /path/to/files
python -m unittest one.py two.py

In both cases all tests should be run, but two OS processes are used in the 1st case and only one in the 2nd case. Which model you choose depends on the requirements of your test suite.

Running Tests Concurrently

Two or more test processes may be run in parallel by increasing the Number of Processes under the Testing tab of the Project Properties dialog.

Running Test Packages

When test files that are located in a package directory (a directory that contains __init__.py), they may be loaded either as package modules, or as top-level modules. Each testing framework defines a default behavior for this case, and this can be overridden using Run as Package Modules under the Testing tab of the Project Properties dialog.

When files are loaded individually as package modules, Wing is running the equivalent of:

python -m unittest package.module

When files are loaded as a top-level package, Wing is running the equivalent of:

python -m unittest module