THINK FIRST·CODE LATER

← All labs

Traceability matrix: coverage and orphans

Problem

Build a traceability report linking requirements to tests.

Input:

R <n>
<n lines: requirementId description...>
T <m>
<m lines: testId covered-requirement-ids separated by commas (or "-" for none)>

Output:

  1. One line per requirement, in input order: REQ-ID: T1, T2 (its tests in input order) or REQ-ID: NOT COVERED.
  2. Coverage: c/n (P%) — requirements with at least one test, P rounded down to an integer.
  3. Orphan tests: ... — tests that cover no known requirement (either - or only unknown IDs), in input order, separated by , , or Orphan tests: none.
  4. Unknown references: ... — test→ID pairs whose ID is not a requirement, as T9->R42, in input order, or Unknown references: none.

Input:

R 3
R1 Login with WKU account
R2 Hide post after 3 reports
R3 Buddy hints only for graded work
T 4
T1 R1
T2 R1,R2
T3 -
T4 R7

Output:

R1: T1, T2
R2: T2
R3: NOT COVERED
Coverage: 2/3 (66%)
Orphan tests: T3, T4
Unknown references: T4->R7

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.