Intelligent Test Runner is only supported in the following versions and testing frameworks:
pytest>=6.8.0
From ddtrace>=2.1.0.
From Python>=3.7.
Requires coverage>=5.5.
unittest
From ddtrace>=2.2.0.
From Python>=3.7.
Setup
Test Visibility
Prior to setting up Intelligent Test Runner, set up Test Visibility for Python. If you are reporting data through the Agent, use v6.40 and later or v7.40 and later.
Activate Intelligent Test Runner for the test service
You, or a user in your organization with the Intelligent Test Runner Activation (intelligent_test_runner_activation_write) permission, must activate the Intelligent Test Runner on the Test Service Settings page.
Run pytest tests with the Intelligent Test Runner enabled
Setting DD_CIVISIBILITY_ITR_ENABLED to true is required while the Intelligent Test Runner support for pytest is in beta.
To run tests on services with the Intelligent Test Runner enabled, set DD_CIVISIBILITY_ITR_ENABLED to true.
DD_CIVISIBILITY_ITR_ENABLED (Optional)
Enable the Intelligent Test Runner coverage and test skipping features Default: (false)
After completing setup, run your tests as you normally do:
You can override the Intelligent Test Runner’s behavior and prevent specific tests from being skipped. These tests are referred to as unskippable tests.
Why make tests unskippable?
The Intelligent Test Runner uses code coverage data to determine whether or not tests should be skipped. In some cases, this data may not be sufficient to make this determination.
Examples include:
Tests that read data from text files
Tests that interact with APIs outside of the code being tested (such as remote REST APIs)
Designating tests as unskippable ensures that the Intelligent Test Runner runs them regardless of coverage data.
Compatibility
Unskippable tests are supported in the following versions and testing frameworks:
pytest
From ddtrace>=1.19.0.
unittest
From ddtrace>=2.2.0.
Marking tests as unskippable in pytest
You can use pytest’s skipif mark to prevent the Intelligent Test Runner from skipping individual tests or modules. Specify the condition as False, and the reason as "datadog_itr_unskippable".
Individual tests
Individual tests can be marked as unskippable using the @pytest.mark.skipif decorator as follows:
Note: This does not override any other skip marks, or skipif marks that have a condition evaluating to True.
Marking tests as unskippable in unittest
You can use unittest’s skipif mark to prevent the Intelligent Test Runner from skipping individual tests. Specify the condition as False, and the reason as "datadog_itr_unskippable".
Individual tests
Individual tests can be marked as unskippable using the @unittest.skipif decorator as follows: