title | sidebar_position |
---|---|
TRG 10.01 - Code Coverage |
1 |
Status | Created | Post-History |
---|---|---|
Draft | 07-Feb-2025 | Initial version created |
Goal: To ensure that all released software components meet sufficient test coverage to guarantee quality, stability, and reliability.
This guideline applies to all software components and projects that are part of the Eclipse Tractus-X release process.
1.1. Code Coverage Threshold
- Quality Gate: The minimum threshold for code coverage (line coverage) should be 80.0%.
- This applies to both unit tests and integration tests.
- Every project not specifically associated to a different Quality Gate will be associated to this one by default.
1.2. Exceptions
Certain code sections may be excluded from counting towards the code coverage percentage if they for example:
- Are themselves test code (no "test of tests").
- Autogenerated code, for example Swagger-generated API clients.
- Configuration files with no logic to test.
- Are experimental or prototype code, for example incomplete implementations hidden behind feature toggles.
- Are boilerplate code or entity classes that follow a known, predictable pattern.
- Code for logging, metrics, or monitoring.
- Depend on platform-specifics, for example hardware that cannot be simulated in a test.
All exceptions should be documented and approved by the project's committer.
2.1. Tools for Code Coverage Measurement
- Recommended tool: SonarCloud as provided by Elipse Tractus-X. Reference link
- Alternatives: SonarQube, JaCoCo
- The tool used to track code coverage should be specified and documented within the respective project.
2.2. Regular Review
- Code coverage should be measured by all Eclipse Tractus-X software products at least once before each release.
- Coverage measurement results should be integrated into CI/CD pipelines and automated as part of the release process.
3.1. Code Review Requirements
- Reviewers must ensure that new or modified code sections are sufficiently covered by test cases.
- Code changes that lower the overall coverage below the defined Quality Gate threshold may only be accepted in exceptional cases.
3.2. Risk Analysis
- If the code coverage value falls below 80.0%, the potential risks should be documented and approved by the release management team.