What is software unit testing?

A unit test is a method that instantiates a small portion of any application and verifies its behavior independently from other parts. Unit tests are narrow in scope and allow for the ability to cover most cases, helping to ensure that the parts work correctly.

To achieve the objectives for a software (SW) unit test, laid out in ISO 26262-6:2018 Clause 9, it is recommended to follow a 4-step verification approach before releasing any SW unit for SW integration and integration testing:

  1. Does the code meet the quality standard?
    • Perform Static Analysis: The static analysis tools can be configured to widely used industry coding standards and coding style guidelines
  2. Does the code do what it should?
    • Perform functional safety requirement based testing
    • Perform non-functional safety requirements based testing
  3. Does the code not do what it should not?
    • Perform Robustness Testing: Test for implausible values, boundary values, execution errors, division by zero, over-flow, under-flow, etc.
  4. Is the code tested enough?
    • Perform Structural Coverage Testing: statement coverage, branch coverage, MC-DC

The 4-step verification approach supports and aligns with the verification planning activities. The actual testing could be performed using any Commercial off-the-shelf (COTS) testing tool suites (which are ISO 26262 qualified and/or certified). If you plan to use COTS tools, look for two categories:

  1. Static Testing: This can be achieved by the combination of code review, compiler configuration, and configurable static analysis tool.
    • Static testing provides verification of:
      • Functional safety and non-safety requirements
      • Coding standards and coding style guidelines
      • Lexical correctness
      • Syntax
      • Semantics
      • Complexity
    • Static testing covers tables 1, 3, 6 and 7 provided by ISO 26262-6:2018.
  2. Dynamic Testing: This can be achieved by the combination of a functional test tool and auto-generation of test cases.
    • Dynamic testing provides verification of:
      • Functional safety and non-safety requirements
      • Interfaces
      • Code coverage
    • Dynamic testing covers tables 7, 8, 9, 10, 11, and 12 provided by ISO 26262-6:2018.

As a reward for following the appropriate combination of unit testing (listed above) for proper software quality assurance, the end result will be clean, easy-to-maintain, loosely coupled, and reusable code, which will make software integration verification easier.

Leave a Reply.