Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hudson, C++ and UnitTest++

Has anyone used Hudson as a Continuous-Integration server for a C++ project using UnitTest++ as a testing library?

How exactly did you set it up?

I know there have been several questions on Continuous Integration before, but I hope this one has a narrower scope.

EDIT: I'll clarify a bit on what I'm looking for. I already have the build set to fail when the Unit-Tests fail. I'm looking for something like Hudson's JUnit support. UnitTest++ can create XML reports (See here). So, perhaps if someone knows how to translate these reports to be JUnit compatible, Hudson will know how to eat it up?

like image 610
Gilad Naor Avatar asked Jan 04 '09 16:01

Gilad Naor


3 Answers

We are actively doing this at my workplace.

Currently, we use a free-style software project to:

  • Check our Subversion repository for updates every 15 minutes
  • Call a windows batch file to clean and build a solution file
    • Project files build and run unit tests as a post-build event
    • Unit test failures are returned by the test main(), thus treated as build errors

I have also tested a configuration that uses the XmlTestReporter included with UnitTest++ to generate output files. The xUnit plugin natively supports this output, along with any other output you can convert, although I had to change the XSL file that came with it in version 0.1.3 to get durations recorded in the test history.

There are a lot of things we would like to improve about our integration; the build logs are long and hard to parse with no coloring or highlighting, etc., but so far it has still been beneficial to us.

like image 171
Patrick Johnmeyer Avatar answered Oct 21 '22 19:10

Patrick Johnmeyer


I checked the xUnit plugin, as Patrick Johnmeyer suggested in the accepted answer. For completeness sakes, here is the driver code:

#include <fstream>
#include "UnitTest++.h"
#include "XmlTestReporter.h"

int main( int argc, char *argc[] ) {
    std::ofstream f("file.xml");
    UnitTest::XmlTestReporter reporter(f);
    return UnitTest::RunAllTests(reporter, UnitTest::Test::GetTestList(), NULL, 0);
}

In Hudson configuration, check "Publish testing tools result report" and point it to "file.xml"

like image 6
Gilad Naor Avatar answered Oct 21 '22 19:10

Gilad Naor


Hudson now has a CppUnit plugin that may do the trick.

like image 4
Soo Wei Tan Avatar answered Oct 21 '22 19:10

Soo Wei Tan