Reporting Templates

The structure of the standard HTML report is defined as a template. Single-file reports are also template based and can be adapted by the user. ctcreport provides coverage information, strictly separated from its representation.

The HTML template delivered with Testwell CTC++ provides an HTML structure together with CSS and JavaScript functions for sorting and expanding, for example. It works with every Layout Configuration.

If you want to adapt this template beyond small adaptions like different CSS styles, it is recommended to get in contact with Verifysoft. If you adapt a template, make a copy and keep the original one.

With installation, four templates are provided in ctcreport folder:

  • html_template.zip: The default template - a ZIP archive like all structured HTML templates.
  • example_csv.csv: A single-file template to generate a CSV format.
  • example_xml.xml: A single-file template to generate an XML format.
  • example_markdown.md: A single-file template to generate Markdown reports.

Additional templates in the same folder, for example my_template.zip, are chosen with option -template my_template for report generation (without file extension). You get an overview over all available templates in your ctcreport folder with ctcreport -h.

Templates can also be placed anywhere and referred to with their path and full file name (with file extension).

Composition of an HTML template

An HTML template consists of three mandatory HTML files:
overview.html
The overview page is generated from this template file. In the report, it is named index.html.
detail.html
All detail pages are generated from this template file, named detail-<n>.html.
sourcecode.html
The source code views are generated from this template files, named source-<n>.html.

Optionally, additional resources like logos, icons, CSS files and JavaScript files may be provided. All additional resources are copied as they are to the output directory, keeping the folder structure from the template.

HTML content

Each of the three template HTML files uses
  • Standard HTML elements.
  • Variables enclosed in $...$ filled with content by ctcreport.
    <span class='Hits'>$Hits$</span>
  • Named loops indicating repetitive parts. Variables usually have a local meaning inside loops.
    <!-- CTC_LOOP("Symbolfiles") -->
    <li>
      <span class='FileName'>$FileName$</span>
      <span class='Timestamp'>$InstrumentationTime$</span>
    </li>
    <!-- CTC_LOOP_END("Symbolfiles") -->
  • Conditional definitions of variables. The variable $_Entities$ is defined in this example, depending on the condition Level2Available.
    <!-- CTC_DEFINE("_Entities"
                    "Level2Available"
                    "$Level1Entities$ and $Level2Entities$"
                    "$Level1Entities$")
    -->                   

Composition of single-file templates

In one text file, coverage information for directories, source files and functions is structured. Functions are the smallest reporting entity, there is no equivalence to source code view.

The file extension of the template determines the default file extension of the output file - there is no format semantic associated with it by ctcreport.

Variables are used in $...$ like in HTML templates. Loop controls are enclosed in {…} instead of HTML comments:

{CTC_LOOP("Symbolfiles")}
FileName: $FileName$
Instrumentation Time: $InstrumentationTime$
{CTC_LOOP_END("Symbolfiles")}

The layout concept does not apply here. Therefore, most conditions for conditional content are meaningless. Use different templates for different needs, for example, to have a CSV report for files only and another one for functions.