Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

Requirements Traceability in Test Automation

ASPICE SWE.4/SWE.6 Traceability

ASPICE requires bidirectional traceability between test cases and requirements. Every test case must reference at least one requirement, and every requirement must be covered by at least one test case. Automated test frameworks make this tractable through metadata annotations:

  • pytest markers: @pytest.mark.req("SWR-001") links test to requirement
  • ECU-TEST attributes: requirement ID stored as test case attribute in workspace
  • Robot Framework tags: [Tags] SWR-001 ASIL-B in test case header

Coverage gap analysis: which requirements have zero test cases? Which test cases reference non-existent requirements? Both are ASPICE audit findings.

Requirements-Based Test Case Generator

Pythontest_design.py
"""Requirement-to-test-case traceability and coverage analysis."""
from dataclasses import dataclass, field
from typing import List

@dataclass
class Requirement:
    req_id: str
    description: str
    asil: str
    test_cases: List[str] = field(default_factory=list)

@dataclass
class TestCase:
    tc_id: str
    title: str
    req_refs: List[str] = field(default_factory=list)

def coverage_analysis(reqs: List[Requirement],
                       tcs: List[TestCase]) -> dict:
    tc_map = {tc.tc_id: tc for tc in tcs}
    req_map = {r.req_id: r for r in reqs}
    uncovered = [r for r in reqs if not any(
        r.req_id in tc.req_refs for tc in tcs)]
    orphaned = [tc for tc in tcs if not any(
        ref in req_map for ref in tc.req_refs)]
    coverage_pct = (len(reqs) - len(uncovered)) / len(reqs) * 100
    return {
        "coverage_pct": round(coverage_pct, 1),
        "uncovered_reqs": [r.req_id for r in uncovered],
        "orphaned_tcs": [tc.tc_id for tc in orphaned]
    }

Equivalence Partitioning for Signal Tests

Pythoneq_partition.py
"""Equivalence partitioning for automotive signal test design."""
from dataclasses import dataclass
from typing import List, Tuple

@dataclass
class SignalPartition:
    name: str
    min_val: float
    max_val: float
    expected_response: str

def generate_eq_partition_tests(
        signal: str,
        partitions: List[SignalPartition]) -> List[dict]:
    """Generate one representative test value per partition."""
    tests = []
    for p in partitions:
        mid = (p.min_val + p.max_val) / 2
        tests.append({
            "signal": signal,
            "value": mid,
            "partition": p.name,
            "expected": p.expected_response
        })
    return tests

VEHICLE_SPEED_PARTITIONS = [
    SignalPartition("below_min",     -10, -0.01, "DTC_SPEED_SENSOR_FAULT"),
    SignalPartition("standstill",      0,   0.5,  "AEB_INACTIVE"),
    SignalPartition("low_speed",      0.5,  30,   "AEB_ACTIVE_LOW"),
    SignalPartition("normal_speed",   30,  200,   "AEB_ACTIVE_FULL"),
    SignalPartition("above_max",     200,  260,   "DTC_SPEED_IMPLAUSIBLE"),
]

Summary

Requirements-based test design forces the team to answer a question that is often avoided: what exactly does "test AEB" mean? Without a systematic technique like equivalence partitioning, test engineers gravitate toward the happy path (normal speed, clear sensor data, no faults) and ignore the boundary conditions and invalid input partitions that are statistically most likely to reveal defects. The equivalence partitioning approach for automotive signals is particularly effective because ECU software is often written with explicit validity checks (if speed < 0 || speed > 250) that create natural partition boundaries. Every condition branch in the ECU software is a partition boundary, and MC/DC coverage requires that both sides of each branch be exercised.

🔬 Deep Dive — Core Concepts Expanded

This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.

Key principles to reinforce:

  • Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
  • Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
  • Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.

🏭 How This Topic Appears in Production Projects

  • Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
  • Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
  • Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.

⚠️ Common Mistakes and How to Avoid Them

  1. Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
  2. Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
  3. Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
  4. Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.

📊 Industry Note

Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.

← PreviousTest Framework Architecture PatternsNext →Hands-On: Framework Selection Guide