-
Notifications
You must be signed in to change notification settings - Fork 8
5 REQ testcov
As a product owner, I want to ensure that implemented requirements are covered by tests, because this is required by safety-critical standards and improves software quality. To represent this information in traceability reports, mantra must be able to store this data.
Multiple tests may be grouped inside one test run. This is similar to a test suite, but test runs represent the execution of a test suite.
The origin of a test run must be stored in mantra, but the storage format should stay flexible to allow different origin variants. For example, test runs could have local files or URLs as origins.
The name of the test run must be used as unique identifier. A test run may be executed multiple times and stored in mantra, but only the newest execution of a test run must be used to calculate the latest requirements coverage.
A test run represents the execution of a test suite, so it must store the date and time the test run was executed.
The name of a test run is used as identifier, and therefore only the newest execution of a test run must be stored.
The test run metadata is programming language, domain, and company specific, so it must be possible to store arbitrary information in mantra, but still be able to access the data for the report generation. e.g. enabled feature flags, target the tests were run on, ...
-
Parents: [
testcov.test_run,exchange.testcov.test.junit]
It must be possible to build a hierarchy of test-runs, because well-supported formats like JUnit allow nested test suites and mantra must be able to exchange test data that adheres to the JUnit format.
The number of test cases of a test run must be the sum of all test cases directly linked to the test run plus the number of test cases of all nested test runs.
However, test runs must only have one parent, to fit the nested structure of formats like JUnit. It is also easier to create a usable schema, by allowing to set a list of test runs as a field in the parent test run. Taking the approach to express hierarchies from the requirement schema would be harder for test runs, because the id of a test run is more tedious to set manually compared to the requirement id.
Implementation Details:
Nested test runs are handled similar to the requirements hierarchy, by having a test run hierarchy table.
Cyclical dependencies between test runs must not be allowed and must be prevented in mantra internally.
A test case must be part of a test run, and must be uniquely identified within the test run.
The state of a test case must be one of the following:
-
passed: The test case passed. -
failed: The test case failed. -
skipped: The test case was skipped.
For state skipped, the reason for skipping the test case must be stored in mantra if such a reason exists in the provided data.
If a test case is not in one of the supported states defined by testcov.test_case.state, the state must be makred as unknown and the test case treated as failed.
The name of a test case must be used as unique identifier per test run a test case is linked to. Testing tools must ensure that the name is unique per test run.
-
Parents: [
testcov.test_case,trace.origin]
The origin of a test case consists of the filepath and line number the test case is defined at. For mantra to link traces to test cases, the filepaths of traces and test cases must use the same relative path origin. Storing filepaths as absolute paths would prevent the database or reports from being portable.
The origin of a trace is its unique identifier, and therefore the test case origin must also be usable as unique identifier.
The metadata of a test case is programming language, domain, project, and company specific, so it must be possible to store arbitrary information in mantra, but still be able to access the data for the report generation. e.g. logs, pre-/post-conditions, description, etc.
-
Parents: [
testcov,trace.origin]
Code coverage data must be associated with test-runs or test cases to know if a requirement was successfully covered by one or more tests.
Note: Preferably, the code coverage data should be linked per test case to get the most accurate requirement coverage, but not all test tools and formats support this fine grain coverage control.
Detecting if a requirement was covered by a test is possible my mapping the line spans of linked traces with the covered lines of the test.
-
Parents: [
testcov.cov.trace_mapping,changes.track.vcs]
If a VCS identifier is provided for test results and code coverage metrics, mantra must validate that traces were collected for this VCS ident, and map coverage metrics to entries related to this VCS ident.
If file hashes are provided for test results and code coverage metrics, mantra must validate that traces were collected for those file hashes, and map coverage metrics to those file entries.
If a file hash is not provided for test results and code coverage metrics, mantra should use the collection timestamps, test run timestamps, spans of detected elements, and statement coverage metrics to map coverage metrics to the most likely hash of a file.
For the trace and code coverage mapping to work, the filepaths of traces and coverage data must use the same relative path origin. Storing filepaths as absolute paths would prevent the database or reports from being portable.
The line numbers for coverage data must start at one for the first line to match with line numbers of traces.
It must be possible to store the line coverage of a specific test case or test-run, because this information is important for safety-critical certifications.
It must be possible to store the branch coverage of a specific test case or test-run, because this information is important for safety-critical certifications.
See https://www.rapitasystems.com/difference-between-decision-coverage-and-branch-coverage for the difference between branch and decision coverage.
It must be possible to store the decision coverage of a specific test case or test-run, because this information is important for safety-critical certifications.
See https://www.rapitasystems.com/difference-between-decision-coverage-and-branch-coverage for the difference between branch and decision coverage.
It must be possible to store the condition coverage of a specific test case or test-run, because this information is important for safety-critical certifications.
It must be possible to store MCDC data of a specific test case or test-run, because this information is important for safety-critical certifications.
It must be possible to store the multiple condition coverage of a specific test case or test-run, because this information is important for safety-critical certifications.
It must be possible to infer the function coverage of a specific test case or test-run based on the line coverage data and collected function information during trace collection.
It should be possible to use static code analysis to approximate requirement coverage of test cases without executing the test case. This improves mantra's usability, because covered requirements could already be displayed while writing a test case.
Please create an issue if you found any spelling mistakes.
You may also create an issue if you think the content of this wiki should be improved.
Note: This wiki is managed in its own repository. Any commits made using the edit button will be overwritten.
Note: Issues for the wiki are handled in the mantra repository, but pull requests for the wiki are handled in the mantra-wiki repository.
This wiki is MIT licensed, and works together with mantra.