Hi, I struggled a bit with getting CruiseControl.NET to work with my Boost.Test C++ unit tests, so I'd like to add a page to the docs briefly explaining how to do it.
It'll be very similar to the instructions at: http://confluence.public.thoughtworks.org/display/CCNET/Using+CruiseControl.NET+with+CppUnit I had hoped to just create a new page directly in the wiki. I've created a Confluence account, but I don't see any edit links. I guess I don't have permission. Would this be a useful addition? What's the best way of getting this added? Can someone give me write access to the wiki, or should I send a draft of the page to someone for inclusion? I've put a patch below showing how I did this -- I'm open to any suggestions or comments on whether this was the best way. In particular, is there any way to pass the results xml through a filter before the "<merge>" action to make it look like NUnit results, rather than editing the dashboard to understand the Boost.Test format? Thanks very much, Rich Index: CruiseControl.NET-config/webdashboard/xsl/unittests.xsl =================================================================== --- CruiseControl.NET-config/webdashboard/xsl/unittests.xsl (revision 22212) +++ CruiseControl.NET-config/webdashboard/xsl/unittests.xsl (revision 22213) @@ -4,6 +4,14 @@ <xsl:output method="html"/> + <xsl:variable name="boosttest.result.list" select="//TestResult"/ > + <xsl:variable name="boosttest.suite.list" select="$boosttest.result.list//TestSuite"/> + <xsl:variable name="boosttest.case.list" select="$boosttest.suite.list/TestCase"/> + <xsl:variable name="boosttest.case.count" select="count ($boosttest.case.list)"/> + <!-- no time yet <xsl:variable name="boosttest.time" select="sum ($nunit2.result.list/test-suite[position()=1]/@time)"/> --> + <xsl:variable name="boosttest.failure.count" select="sum ($boosttest.suite.list/@test_cases_failed)"/> + <xsl:variable name="boosttest.notrun.count" select="sum ($boosttest.suite.list/@test_cases_skipped)"/> + <xsl:variable name="nunit2.result.list" select="//test-results"/> <xsl:variable name="nunit2.suite.list" select="$nunit2.result.list//test-suite"/> <xsl:variable name="nunit2.case.list" select="$nunit2.suite.list/ results/test-case"/> @@ -24,9 +32,9 @@ <xsl:variable name="junit.error.count" select="count ($junit.error.list)"/> <xsl:variable name="total.time" select="$nunit2.time + $junit.time"/> - <xsl:variable name="total.notrun.count" select="$nunit2.notrun.count"/> - <xsl:variable name="total.run.count" select="$nunit2.case.count + $junit.case.count - $total.notrun.count"/> - <xsl:variable name="total.failure.count" select="$nunit2.failure.count + $junit.failure.count + $junit.error.count"/> + <xsl:variable name="total.notrun.count" select="$nunit2.notrun.count + $boosttest.notrun.count"/> + <xsl:variable name="total.run.count" select="$nunit2.case.count + $junit.case.count + $boosttest.case.count - $total.notrun.count"/> + <xsl:variable name="total.failure.count" select="$nunit2.failure.count + $junit.failure.count + $boosttest.failure.count + $junit.error.count"/> <xsl:template match="/"> <table class="section-table" cellpadding="2" cellspacing="0" border="0" width="98%"> Index: CruiseControl.NET-config/server/ccnet.config =================================================================== --- CruiseControl.NET-config/server/ccnet.config (revision 22212) +++ CruiseControl.NET-config/server/ccnet.config (revision 22213) @@ -12,7 +12,13 @@ <modificationDelaySeconds>0</modificationDelaySeconds> <name>$(project)</name> <prebuild /> - <publishers> + <publishers> + <!-- merge in the results of the unit test --> + <merge> + <files> + <file>Debug\results.xml</file> + </files> + </merge> <xmllogger> <logDir>c:\build-logs\$(project)</logDir> </xmllogger> @@ -66,6 +72,12 @@ <project /> <solutionfile>XXX.sln</solutionfile> </devenv> + <!-- XXX unit tests --> + <exec> + <executable>XXXTests.exe</executable> + <baseDirectory>Debug</baseDirectory> + <buildArgs>--report_format=xml --report_level=detailed</ buildArgs> + </exec> </tasks> <triggers> <intervalTrigger> Index: XXXTests/stdafx.h =================================================================== --- trunk/XXXTests/stdafx.h (revision 22207) +++ trunk/XXXTests/stdafx.h (revision 22208) @@ -9,9 +9,26 @@ #include <stdio.h> #include <tchar.h> +#include <iostream> #define BOOST_TEST_MODULE XXX Tests #include <boost/test/unit_test.hpp> +#include <boost/test/results_reporter.hpp> #define UNIT_TESTS #define UNIT_TESTABLE + +#include <fstream> + +struct ReportRedirector +{ + std::ofstream out; + + ReportRedirector() : out("results.xml") + { + assert( out.is_open() ); + boost::unit_test::results_reporter::set_stream(out); + } +}; + +static ReportRedirector r;
