Running and Debugging Tests
Tests can be run and debugged from the Testing menu, in the following ways:
- Run All Tests runs all the unit tests listed in the Testing tool.
- Run Tests in Current File runs all the tests found in the current editor.
- Run Tests at Cursor runs the test or tests at the caret or selection in the current editor
- Run Failed Tests reruns all the tests marked as failed in the Testing tool.
- Run Stale Tests reruns all the tests marked as stale in the Testing tool, based on edits made since the tests were last run.
- Run Tests Again reruns all the tests that were run the last time tests were run.
Test files or individual tests may be selected in the Testing tool and run with the Run button or using the items in the right-click context menu.
By default, tests are run in the order they are shown in the Testing tool. This order can be changed with Test Run Order in the tool's Options menu, as described under Execution Options below.
To stop running tests, press Abort Tests in the Testing tool or select Abort Running Tests from the Testing menu.
To clear stored test results from the Testing tool, use Clear All Results in the Options menu, or select tests and use Clear Selected Results in the right-click context menu to clear only the results for those tests.
Debugging
For each of the 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.
When tests are debugged, output goes to the Debug I/O tool and the contents of the Testing tool are not updated with the results of the test.
Unexpected Exceptions
Some testing frameworks such as pytest may stop at internal exceptions that should be ignored by clicking on Ignore this exception location in the Exceptions tool. This occurs when the testing framework raises and then handles AssertionError in order to probe the capabilities of the running Python. By default, Wing will always stop on assertions, even if they are handled, because in most cases a failing assertion indicates a bug in code. Once ignored, Wing won't stop on these internal exceptions again and debugging can proceed as usual.
Specifying Environment and Command Line Arguments
The Python environment used to run unit tests, and also any command line arguments to pass to the tests, can be set with Environment under the Testing tab of Project Properties.
To select different environments for different test files, set Environment instead in File Properties for each file. File Propertiess` are accessed by right-clicking on the test file in the editor or in the ``Testing or Project tools.
Execution Options
There are several options available for how Wing runs unit tests.
Process Model
When multiple test files are run at once, they may be run in a separate process for each file (the default), or all test files in one directory may be run in a single process. This is selected with Process Model under the Testing tab of Project Properties.
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 instead 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 processes are used in the first case and only one in the second 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 Project Properties. This can increase performance on systems with multiple CPU cores, but may introduce problems if the tests do not handle concurrency well.
Running Test Packages
When test files that are located in a package (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, but this can be overridden using Run as Package Modules under the Testing tab of Project Properties.
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
Skipping Slow Tests
To avoid waiting on slow tests during development, enable Skip Slow Tests in the Options menu of the Testing tool. When this is set, running all tests or running a whole file skips any file whose last total run time reached the Slow Test Threshold. Tests that you select and run individually are always run even if slow, and files that have never been run are not skipped.
Use Run Slow Tests in the same menu to run just the tests whose last run time reached the threshold, for example to check them on their own after skipping them.
Test Run Order
By default tests are handed to the test runner in the order they are shown in the Testing tool. Use Test Run Order in the Options menu of the Testing tool to instead run Fastest First or Slowest First, ordered by each test or file's last known run time. Units with no known run time are run last, in display order.
Fixing Failing Tests with Claude Code
When tests fail, you can ask Claude Code to fix them by clicking the FIX button in the Testing tool. This button appears next to the run and debug buttons when Claude Code has been set up for the project (see Setting Up Claude Code).
You can select one or more failed tests, or select a file or class node to include all failed tests under it. Then click the FIX button or use the right-click context menu. Wing will:
For a single failed test:
- Compose a detailed request containing the test name, file, exception, traceback, and test output.
- Open a dedicated Claude Code instance labeled Fix Test.
- Send the request to Claude Code, which will analyze the failure details, fix the code, and run the test to verify the fix.
For multiple failed tests:
- Compose a request listing the failing tests grouped by file and class.
- Open a dedicated Claude Code instance labeled Fix Test.
- Send the request to Claude Code, which will work through the tests one at a time — running each to get failure details, fixing the code, and moving on to the next. Tests that now pass due to earlier fixes are skipped automatically.
Claude Code uses Wing's testing MCP server to run and verify tests, so it works with the same Python environment and test framework configured in your project.
If Claude Code has not yet been set up (directory trust, MCP server approval, etc.), Wing will show a dialog asking you to complete the setup first.
