Project

General

Profile

C++TESK Cookbook » History » Version 1

Alexander Kamkin, 07/31/2013 06:29 PM

1 1 Alexander Kamkin
h1. C++TESK Cookbook
2
3
h2. Developing a Report Printer
4
5
If you want to change the way the tool describes failures (you don’t like the printing style or you get used to work with a different format or you need to integrate your test system with a bug tracker or whatever), the best solution is probably to write your own report printer. It can be easily done by defining one method in a printer class and registering the printer in C++TESK Report Subsystem. The steps are as follows.
6
7
h4. Step 1. Printer Definition
8
9
<pre><code class="cpp">
10
#include <hw/report/printer.hpp>
11
12
using namespace cpptesk::hw::report;
13
14
// You need to inherit from the base printer
15
structure MyPrinter: public ReportPrinter
16
{
17
    // ... and to define (override) the print method.
18
    virtual void print(std::ostream &out, const Report &report) { ... }
19
};
20
</code></pre>
21
22
h4. Step 2. Printer Registration
23
24
<pre><code class="cpp">
25
// If the printer is ready, it may be registered.
26
CPPTESK_MODEL(MyModel)
27
{
28
    MyModel()
29
    {
30
        // Printers are registered in a model.
31
        registerReportPrinter(new MyPrinter());
32
        ...
33
    }
34
};
35
</code></pre>
36
37
Before developing your report printer make sure that printer you need to develop (or a similar one) doesn’t exist in the library.