Unittests

The following Unit Test frameworks are supported:

Unit Tests

Prerequisites

Select and Enable a Test Framework

Select and Enable a Test Framework
UnitTests are turned off by default. Unit Testing of Python code is supported by enabling one of the above Unit Tests via the user or workspace settings files (settings.json), as follows:

  • Open the user or workspace settings file (settings.json)
  • Pick a unit test framework and enable one of them as follows:
// Place your settings in this file to overwrite default and user settings.
{
    "python.unitTest.pyTestEnabled": true,
    "python.unitTest.unittestEnabled": false,
    "python.unitTest.nosetestsEnabled": false

Note: Use the value true to enable a particular unit test framework and false to disable.

Running Tests

Tests can be run (executed) a number of ways.

  1. Click the Run Tests statusbar button and select any one of the options such as Run All Tests in the subsequent list of options displayed.
  2. Select a file from the explorer and from the context menu select Run Unit Tests
  3. Open a test file and click the Test code lens.

For further (advanced) options and details on running tests, go [here].

Discover Tests

More Options

unittest Framework

pytest Framework

nose Framework

Topics:

Unittests

The following Unit Test frameworks are supported:

Unit Tests

Prerequisites

Select and Enable a Test Framework

Select and Enable a Test Framework
UnitTests are turned off by default. Unit Testing of Python code is supported by enabling one of the above Unit Tests via the user or workspace settings files (settings.json), as follows:

  • Open the user or workspace settings file (settings.json)
  • Pick a unit test framework and enable one of them as follows:
// Place your settings in this file to overwrite default and user settings.
{
    "python.unitTest.pyTestEnabled": true,
    "python.unitTest.unittestEnabled": false,
    "python.unitTest.nosetestsEnabled": false

Note: Use the value true to enable a particular unit test framework and false to disable.

Running Tests

Tests can be run (executed) a number of ways.

  1. Click the Run Tests statusbar button and select any one of the options such as Run All Tests in the subsequent list of options displayed.
  2. Select a file from the explorer and from the context menu select Run Unit Tests
  3. Open a test file and click the Test code lens.

For further (advanced) options and details on running tests, go [here].

Discover Tests

More Options

unittest Framework

pytest Framework

nose Framework