GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||
GeezerVison is showing docs.datadoghq.com — Code Coverage Flags For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/code_coverage/flags.md.
A documentation index is available at /llms.txt.
Code Coverage FlagsThis product is not supported for your selected Datadog site. (). OverviewFlags in Code Coverage let you organize and filter coverage data by custom categories. Use flags to separate coverage reports by test type (unit, integration, end-to-end), runtime version (JVM 17, JVM 21), or any other criteria relevant to your project. With flags, you can:
Flags vs. monorepo support featuresCode Coverage provides two complementary ways to filter coverage data:
For example, the same source file might be covered by both unit tests and integration tests. Monorepo support features cannot distinguish between these because they operate on file paths. Flags allow you to track unit test coverage and integration test coverage separately by tagging each report with a flag indicating the test type or runtime version. How flags work with report mergingDatadog automatically merges coverage reports for the same commit. When using flags:
When a report is tagged with multiple flags, its coverage data is merged into each flag independently. Consider the following example where three reports are uploaded for the same commit:
The resulting coverage data for each flag is:
This allows you to answer questions like “What is my unit test coverage?” ( For details on how line data from overlapping reports is combined, see Code Coverage Calculation. Add flags to coverage reportsAdd flags with the CLIThe --flags argument is available in datadog-ci v5.6.0 and later.To add flags to a coverage report, use the A single report can have multiple flags, allowing you to slice coverage data in different ways: In this example, the coverage data is available under both the Add flags to automatically uploaded reportsAutomatic report uploads are available in several Test Optimization libraries. Of those libraries, only the following versions support
Ruby, Python, and Java libraries do not support For a supported version, set This example attaches the same flags as LimitationsThe following limitations apply to both automatically uploaded reports and reports uploaded with
View coverage by flagIn the Code Coverage UI, select a repository and use the Flag filter to view coverage data for a specific flag. This filter appears alongside the Code Owner and Service filters. When you select a flag, the coverage metrics update to show only the data from reports tagged with that flag. Set up PR Gates with flagsYou can configure PR Gates to enforce coverage thresholds for specific flags. This allows you to enforce different coverage requirements for different test types or runtime versions. You can create flag-specific gates in one of two ways:
Rules from both sources are evaluated when a pull request is opened or updated. See Configuration for YAML gate syntax and examples. Create a flag-specific gate in the Datadog UI
How flag gates work
Example configurationsEnforce high coverage for unit tests:
Require all new code in integration tests to be tested:
Enforce coverage for specific runtime versions:
Multiple gates per repositoryYou can create multiple gates for the same repository, each applying to different flags. This allows you to enforce different coverage standards for different test types or runtime versions. Common use casesSeparate unit and integration testsUpload unit test and integration test coverage with different flags to track them independently: Track coverage across runtime versionsIf your CI matrix tests against multiple runtime versions, flag each report accordingly: Further readingAdditional helpful documentation, links, and articles: | ||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |