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

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s4-3-data-1.txt

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
What your program must print for s4-3-data-1.txt
R1: T1, T2
R2: T2
R3: NOT COVERED
Coverage: 2/3 (66%)
Orphan tests: T3, T4
Unknown references: T4->R7

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s4-3-data-1.txt

Windows PowerShell does not understand <:

Get-Content s4-3-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

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.