-
Notifications
You must be signed in to change notification settings - Fork 1.5k
unitest (Standard Unit testing) Framework
This section outlines the details necessary to get you up and start with using the pythong (built in) unit testing framework with Visual Studio Code.
Assign the value true
against the setting python.unitTest.unittestEnabled
as outlined here.
Ensure all other test frameworks have been disabled (i.e. have the value false
).
The default pattern used to match test files is test*.py
.
This can be configured as follows:
- Open the user or workspace settings (settings.json)
- Add the configuration item (
"-p *_test.py"
) if not found (else alter it as follows):
"python.unitTest.unittestArgs": [
"-p *_test.py"
],
Note:
- The above is merely an example that picks all files ending with
_test.p
to be treated as test files. - Further details and values of this config item can be found here.
The default verbosity is 'v'. This can be configured as follows:
- Open the user or workspace settings (settings.json)
- Add the configuration item (
"-v"
) if not found (else alter it as follows):
"python.unitTest.unittestArgs": [
"-v"
],
- If you do not require a verbose output, simple remove the "-v" entry as follows:
"python.unitTest.unittestArgs": [
],
This is the directory to start the test discovery (defaults to the project/workspace root directory).
This can be configured as follows:
- Open the user or workspace settings (settings.json)
- Add the configuration item (
"-s ./tests"
) if not found (else alter it as follows):
"python.unitTest.unittestArgs": [
"-v",
"-s ./tests"
],
Note:
- Further details and values of this config item can be found here.
Use this option to stop the test run on the first error or failure.
By default this is disabled, i.e. if a test fails the test run continues with other tests.
This can be configured as follows:
- Open the user or workspace settings (settings.json)
- Add the configuration item (
"-f"
) if not found (else alter it as follows):
"python.unitTest.unittestArgs": [
"-v",
"-f"
],
Note:
- Further details and values of this config item can be found here.