I would like to create a report summary at the beginning of my report. The report consists of sections/subsections that outline a test that either passed or failed.
The idea is to only add \passed or \failed in a section to print out passed/failed as well as add passed/failed to the report summary together with the test name (test name equals title of that section - see image below for an example).
The dynamic list from this post seemed to be a great solution, however I can't figure out how to pass along the test name. I've tried many things like adding \label{\thetitle} to each section to reference using \nameref{\thetitle}. But I guess the problem always is that the list is printed before everything else happens. Maybe writing to a temp file is a solution, or some different solution using a modified TOC, or maybe I'm completely off track and there are much better solutions. I'm happy to hear you suggestions.
Just for a better understanding: The goal is to generate this report automatically, that's why it is important to not find a hard coded solution but one that can scale dynamically.
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\defineList}{m}
{\seq_new:c { g_chrillof_list_#1_seq }}
\NewDocumentCommand{\addToList}{mm}
{\iow_shipout:cn { @auxout } { \chrillofaddtolist { #1 } { #2 } }}
\NewDocumentCommand{\chrillofaddtolist}{mm}
{\seq_gput_right:cn { g_chrillof_list_#1_seq } { #2 }}
\NewDocumentCommand{\printList}{m}
{\seq_use:cn { g_chrillof_list_#1_seq } { }}
\AtEndDocument{\cs_set_eq:NN \chrillofaddtolist \use_none:nn }
\ExplSyntaxOff
\defineList{ReportSummary}
\newcommand{\passed}{
\textcolor{green}{
\textbf{PASSED}
\addToList{ReportSummary}{PASSED & Test Name X\}}
}
\newcommand{\failed}{
\textcolor{red}{
\textbf{FAILED}
\addToList{ReportSummary}{FAILED & Test Name X\}}
}
\begin{document}
\tableofcontents
\section{Report Summary}
\begin{tabular}{l l}
Status & Test Name\
\hline
\printList{ReportSummary}
\end{tabular}
\section{Test 1}
\passed
\section{Test 2}
\subsubsection{Test 2a}
\failed
\subsubsection{Test 2b}
\passed
\end{document}

