Verification Templates#

Verification Specification Template
status: valid

The sections below are seen as typical ways when writing tests and their specification. Their usage differs based on the selected testing framework and the implementation language of the component(s).

Allowed values for TestType and DerivationTechnique and a short guide when to use which are available in the Quick Guide: What to use when. Multiple values can be given for both.

The Ids used in PartiallyVerifies and FullyVerifies are the Ids of component, feature or stakeholder requirements or architectural element, depending on the test level (see Verification Documentation ...).

The Ids used in RequiredForFullyVerifying are the unique identifiers of test cases (see Test Specification Guideline). This attribute is only used on an anchor test together with FullyVerifies to declare the complete set of test cases which together fully cover the referenced requirement(s) (see Linking Requirements to Tests).

C++#

For C++ code gTest is a commonly used and accepted test framework to write test cases for C/C++ code.

Each test case requires a link to one or more requirement/design element.

For linking C++ tests to requirements record properties shall be used. Attributes which are common for all test cases can be specified in the Setup Function (SetUp()), the other attributes which are specific for each test case need to be specified within the test case:

Below code is exemplary and can be used as a template when writing test cases.

C++ Properties Template#

class TestSuite : public ::testing::Test{
   public:
      void SetUp() override
      {
         RecordProperty("TestType", "<TestType>");
         RecordProperty("DerivationTechnique", "<DerivationTechnique>");
         ...
      }
};

TEST_F(TestSuite, <Test Case>)
{
   RecordProperty("PartiallyVerifies", "ID_2, ID_3, ...");
   RecordProperty("FullyVerifies", "ID_4, ID_5, ...");
   // Only on an anchor test: unique identifiers of the additionally required test cases
   // which together with this test fully cover the requirement(s) in FullyVerifies
   RecordProperty("RequiredForFullyVerifying", "TestUID_1, TestUID_2, ...");
   RecordProperty("Description", "<Description>");

   ASSERT ...
}

When writing test cases using gTest, they shall follow the recommendations from the official gTest documentation. For very basic start follow http://google.github.io/googletest/primer.html For advanced information follow http://google.github.io/googletest/advanced.html

Rust#

The rust community uses the terms unit test and integration test. Where unit test basically represents what the project considers as unit tests the term “integration test” in rust can be treated for component and feature testing. Details on the definition an the test organization in rust can be found here: https://doc.rust-lang.org/book/ch11-03-test-organization.html

Each test case requires a link to one or more requirement/design element.

Below code is exemplary and can be used as a template when writing test cases.

Rust Properties Template#

For linking Rust tests to requirements #[record_property] shall be used:

use test_properties::record_property;

#[record_property("PartiallyVerifies", "ID_2, ID_3, ...")]
#[record_property("FullyVerifies", "ID_4, ID_5, ...")]
// Only on an anchor test: unique identifiers of the additionally required test cases
// which together with this test fully cover the requirement(s) in FullyVerifies
#[record_property("RequiredForFullyVerifying", "TestUID_1, TestUID_2, ...")]
#[record_property("Description", "<Description>")]
#[record_property("TestType", "<TestType>")]
#[record_property("DerivationTechnique", "<DerivationTechnique>")]
#[test]
fn test_case_function() {
   ...
}

When writing test cases in rust, they shall follow the recommendations from the official rust documentation. https://doc.rust-lang.org/book/ch11-01-writing-tests.html

Python#

When writing test cases in python, this should be done using pytest. Note that python unittest does not support metatags and therefore should not be considered as test framework.

Each test case requires a link to one or more requirement/design element.

For linking python tests to requirements metadata shall be used.

For allowed values for test_type & derivation_technique please check Linking Requirements to Tests

Below code is exemplary and can be used as a template when writing test cases.

Python Properties Template#

@add_test_properties(
      partially_verifies=["tool_req__docs_dd_link_source_code_link"],
      test_type="requirements-based",
      derivation_technique="requirements-analysis",
)
def test_group_by_need_empty_list():
      """Test grouping empty list of needlinks."""
      ...

If several test cases are needed to fully cover a requirement, one of them is selected as anchor test and declares the complete test set via required_for_fully_verifying:

@add_test_properties(
      fully_verifies=["tool_req__docs_dd_link_source_code_link"],
      required_for_fully_verifying=[
            "test_group_by_need_empty_list",
            "test_group_by_need_single_need",
      ],
      test_type="requirements-based",
      derivation_technique="requirements-analysis",
)
def test_group_by_need_multiple_needs():
      """Test grouping multiple needlinks. Anchor test declaring the complete test set."""
      ...

When writing test cases in python, they shall follow the recommendations from the official python and community documentation. https://docs.python-guide.org/writing/tests/