I want to write a specification. It has a section listing all features. Another section lists tests. Each test must reference the feature it tests.

Now by TeX-magic, I want untested features be colored red. I also want features to get a list of tests, which test it. Ideally clickable references to jump back and forth in pdfs and numbered.

More concretely, a hypothetical specification:

\feature{Features have a List of Tests}{at-feature-list}
The first part is the title, the second a label, like for \\label
\feature{Untested Features are red}{123}
\feature{Tests link to Features they test}{crossref}

\ftest{A list of Features}{at-feature-list,123}
Create an example listing...

It should output like

F1. Features have a List of Tests

Tested by: T1

The first part is the title, the second a label, like for \label

F2. Untested Features are red

Tested by: T1

F3. Tests link to Features they test (colored red!)

Tested by: -

T1. A list of Features

Testing: F1, F2

As far as I know, there is no package for this. Implementing \feature and \ftest probably implementing something similar to \label and \ref.

  • 1
    this can be done using rdfref package, I thing. It doesn't have documentation, unfortunately. but you can see what it can do in this answer, or another one – michal.h21 Dec 2 '16 at 19:40

Thanks to michal.h21 and his rdfref package I was able to build something, which is nearly there.

The relevant part of the document looks like this:




\test{First Start}{tst:first}


The output is:

F1 Foo   Tested by: 
F2 Bar   Tested by: T1 T2


T1 First Start   Testing: F2
T2 Trial   Testing: F2

The TeX macros to get there are:


  { \GetProperty{#1}{pfl:tstid} }}
  { \GetProperty{#1}{pfl:fncid} }}


  \par\textbf{F\arabic{functionality} #1}\rdflabel{#2}
       Tested by: \Bind{?t}{pfl:tests}{#2}{ \testlink{\GetVal{?t}} }
  }{{\color{red}{NOT TESTED}}}

  \par\textbf{T\arabic{test} #1}\rdflabel{#2}
  Testing: \Bind{#2}{pfl:tests}{?f}{ \functionalitylink{\GetVal{?f}} }

The \AddProperty calls are relative to the previous \rdflabel and store triples like (tst:trial,pfl:tests,fnc:bar).

Then \Bind{?t}{pfl:tests}{#2}{ \testlink{\GetVal{?t}} } outputs the list of links. The query (?t,pfl:tests,fnc:bar) looks for all triples, where the second and third element matches. It outputs a \testlink for each found triple with ?t bound to the first triple element.

There is also the (id,pfl:is-tested,yeah) triples. They are used for the \IfProperty checks. If there is no such triple for an id, then a red warning NOT TESTED is printed, instead of the backlinks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.