Prior to setting up Test Impact Analysis, set up Test Optimization for Ruby. If you are reporting data through the Agent, use v6.40 and later or v7.40 and later.
Activate Test Impact Analysis 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 Test Impact Analysis on the Test Service Settings page.
Run tests with Test Impact Analysis enabled
After completing setup, run your tests as you normally do.
Disabling skipping for specific tests
You can override the Test Impact Analysis’s behavior and prevent specific tests from being skipped. These tests are referred to as unskippable tests.
Why make tests unskippable?
Test Impact Analysis 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)
Tests that run external processes
Tests that depend on global shared state (for example, caches created by a different test or process)
Tests that use forked processes (per test code coverage only collects coverage for the main process)
Integration tests that use capybara or selenium-webdriver
Designating tests as unskippable ensures that Test Impact Analysis runs them regardless of coverage data.
Marking tests as unskippable
To ensure that RSpec tests within a specific block are not skipped, add the metadata key datadog_itr_unskippable with the value true to any describe, context, or it block. This marks all tests in that block as unskippable.
# mark the whole file as unskippableRSpec.describeMyClass,datadog_itr_unskippable:truedodescribe"#my_method"docontext"when called without arguments"doit"works"doendendendend# mark one test as unskippableRSpec.describeMyClassdodescribe"#my_method"docontext"when called without arguments"doit"works",datadog_itr_unskippable:truedoendendendend# mark specific block as unskippableRSpec.describeMyClassdodescribe"#my_method",datadog_itr_unskippable:truedocontext"when called without arguments"doit"works"doendendendend
To mark an entire feature file as unskippable in Cucumber, use the @datadog_itr_unskippable tag. This prevents Test Impact Analysis from skipping any of the scenarios defined in that feature file.
To make only specific scenarios unskippable, apply this tag directly to the desired scenario.
To make an entire Minitest subclass unskippable, use the datadog_itr_unskippable method. If you want to mark specific tests within the subclass as unskippable, provide the names of these test methods as arguments to the datadog_itr_unskippable method call.
# mark the whole class unskippableclassMyTest<Minitest::Testdatadog_itr_unskippabledeftest_my_methodendend# here only test1 and test2 are unskippab;eclassMyTest<Minitest::Testdatadog_itr_unskippable"test1","test2"deftest1enddeftest2enddeftest3endend
Temporarily disabling Test Impact Analysis
Test Impact Analysis can be disabled locally by setting the DD_CIVISIBILITY_ITR_ENABLED environment variable to false or 0.
DD_CIVISIBILITY_ITR_ENABLED (Optional)
Enable the Test Impact Analysis coverage and test skipping features Default: (true)
Further Reading
Additional helpful documentation, links, and articles: