9

I'm using Eclipse CDT and Boost.Test(with Boost.Build). I would like Eclipse to parse output of Boost.Test generated during by run of test suites during build.
Does anybody know how to achieve this? Thanks in advance

Björn Pollex
  • 70,106
  • 28
  • 177
  • 265

3 Answers3

15

Go to Window > Preferences. In the preferences dialog, choose C/C++ > Build from the options tree. Under error parsers, click "Add..." In the new dialog, replace "Regex Error Parser" with something like "Boost Unit Test Error Parser".

In the Error Parser Options pane, add the following lines. I can't guarantee that these rules catch all possible output from boost unit tests, but so far they work for me, and we can always add more later:

Severity | Pattern                                          | File | Line | Description
Error    | (.*)\((\d*)\): ((fatal )?error in ".*":.*)       | $1   | $2   | $3
Error    | \*\*\* (\d* failures detected in test suite ".*")|      |      | $1
Info     | (.*)\((\d*)\): (last checkpoint)                 | $1   | $2   | $3

Note that the new parser will not automatically be used in existing projects. To enable the parser for an existing project, go to Project > Properties, C/C++ Make Project, Error Parsers tab. If the newly added parser is not in the list, click "Restore Defaults", and it should now be available.

Mark Stijnman
  • 151
  • 1
  • 3
  • 4
    Very, very cool. Thanks for the great answer. Works for me on Eclipse 3.6.2. The location of the Project setting to enable the new parser for existing projects has changed slightly. It's now Project > Properties > C/C++ Build > Settings > Error Parsers tab (or just enter "settings" in the "type filter text" box.) – Jack Kelly Jul 10 '11 at 16:41
2

There is also a nice plugin called cdt c/c++ tests runner, which supports Google test, boost test, and qt test.

You can find instructions at the following link:

https://github.com/xgsa/cdt-tests-runner/wiki/Tutorial

I have been using it for a while, and found it efficient and nice. It has features like a JUnit plugin for Java.

David Duncan
  • 1,225
  • 8
  • 14
RainSia
  • 113
  • 1
  • 7
0

I had the same problem of my IDE (gedit) not recognizing the output format of Boost.Test (which is not compatible with gnu and clang output for some reason).

You can change the output format programmatically by sticking this in your test(s):

#include<boost/test/output/compiler_log_formatter.hpp>
struct gedit_config{
    struct formatter : boost::unit_test::output::compiler_log_formatter{
        void print_prefix(std::ostream& out, boost::unit_test::const_string file, std::size_t line){
            out<< file <<':'<< line <<": ";
        }
    };
    gedit_config(){boost::unit_test::unit_test_log.set_formatter(new formatter);}
};
BOOST_GLOBAL_FIXTURE(gedit_config);

(original answer here: https://stackoverflow.com/a/64619245/225186)

alfC
  • 10,293
  • 4
  • 42
  • 88