Project

General

Profile

Actions

C++TESK Cookbook » History » Revision 1

Revision 1/5 | Next »
Alexander Kamkin, 07/31/2013 06:29 PM


C++TESK Cookbook

Developing a Report Printer

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.

Step 1. Printer Definition

#include <hw/report/printer.hpp>

using namespace cpptesk::hw::report;

// You need to inherit from the base printer
structure MyPrinter: public ReportPrinter
{
    // ... and to define (override) the print method.
    virtual void print(std::ostream &out, const Report &report) { ... }
};

Step 2. Printer Registration

// If the printer is ready, it may be registered.
CPPTESK_MODEL(MyModel)
{
    MyModel()
    {
        // Printers are registered in a model.
        registerReportPrinter(new MyPrinter());
        ...
    }
};

Before developing your report printer make sure that printer you need to develop (or a similar one) doesn’t exist in the library.

Updated by Alexander Kamkin over 11 years ago · 5 revisions