Unit Testing
Wing's Testing tool provides a convenient way to run and debug unit tests written using the standard library's unittest and doctest modules, pytest, nose, and the Django testing framework.
Adding Tests
Tests are added from the Testing menu, with Add Single File and Add Current File to add individual files, or with Add Files from Project to apply a filter to the set of all files in the project. For details, see Project Test Files.
The testing framework used to run files is selected with Default Test Framework under the Testing tab of Project Properties or with Test Framework under the Testing tab of File Properties for individual test files.
Running Tests
To run tests, press the Run button in the Testing tool, or use one of the items in the Testing menu. For details, see Running and Debugging Tests.
In Wing Pro, the Claude Code AI agent can also write and run tests for you: use Write Tests in the Testing menu to generate tests for selected code, and the one-click FIX action on a failing test hands the failure to the agent to diagnose and resolve. See AI Actions.
While tests are running, the Testing tool updates to indicate the status of the run. After the tests have finished running, the status icon for each test will change to indicate the result of the run:
indicates the test passed
indicates the test failed
indicates the test was skipped
indicates the test was not run or did not complete
Viewing Test Results
Individual tests may be expanded to show output generated by the test or any exception that occurred. Exceptions, including any PEP 3134 chained exceptions, may be expanded to display tracebacks.
Collapse All Tests and Expand All Failed Tests in the Options menu in the Testing tool can be used to quickly hide all test details, or show details only for failed tests.
Double-click on any test or use Goto Source in the right-click context menu in the Testing tool to display the source code for the test in the editor.
To focus on a subset of the test files, enter a fragment matching those test file names into the File Filter field in the top right of the Testing tool. Restore the field to blank redisplays the entire lists of tests.
To focus on tests with a particular result, use the Status menu next to the File Filter field in the top right of the Testing tool. This menu independently toggles display of tests according to their last-run status: Not yet run, Failed, Skipped, and Passed. Use Show All to clear the filter and redisplay tests of every status.
Output shown for tests may optionally be wrapped to fit the display by checking Wrap Output Lines in the Options menu of the Testing tool.
Run Times
Each test, test class, and test file shows how long it took to run and how long ago it was last run, shown after the name as for example - 8s | 2m ago. For a test class or file, the time is the total of the tests within it and the elapsed time is for the most recent of those tests. Tests, classes, or files whose run time reaches the slow-test threshold are shown in red to make slow tests easy to spot. The threshold defaults to 30 seconds and may be changed (or set to 0 to disable slow-test highlighting) with the Slow Test Threshold value in the Testing section of Project Properties.
The Options menu of the Testing tool can use this threshold to Skip Slow Tests when running all tests or a whole file, to Run Slow Tests on their own, and to set the Test Run Order to fastest or slowest first. For details, see Running and Debugging Tests.
Section Contents
15.1. Running and Debugging Tests
15.2. Code Coverage
15.2.0. Coverage Configuration
15.2.1. Code Coverage Environments
15.2.2. Coverage Data Files
15.2.3. How Code Coverage Works
15.3. Running unittest Tests from the Command Line
