<p>I'm compiling a NAnt project on linux with TeamCity Continuous Integration server. I have been able to generate a test report by running NAnt on mono thru a Command Line Runner but don't have the options of using the report like a NAnt Runner. I'm also using MBUnit for the testing framework.</p>

<p>How can I merge in the test report and display "Tests failed: 1 (1 new), passed: 3049" for the build?</p>

<p><strong>Update:</strong> take a look at MBUnitTask its a NAnt task that uses sends messages that TeamCity expects from NUnit so it lets you use all of TeamCity's features for tests.</p>

<p><a href="http://code.google.com/p/nant-extensions/wiki/MbUnitTask" rel="noreferrer">MBUnitTask</a></p>

<p><strong>Update:</strong> Galio has better support so you just have to reference the Galio MBUnit 3.5 dlls instead of the MBUnit 3.5 dlls and switch to the galio runner to make it work.</p>

[{'answer_id': 4144, 'author': 'Lance Fisher', 'author_id': 571, 'author_profile': 'https://Stackoverflow.com/users/571', 'pm_score': 2, 'selected': False, 'text': '<p>TeamCity watches the command line output from the build.  You can let it know how your tests are going by inserting certain markers into that output See <a href="http://www.jetbrains.net/confluence/display/TCD3/Build+Script+Interaction+with+TeamCity" rel="nofollow noreferrer">http://www.jetbrains.net/confluence/display/TCD3/Build+Script+Interaction+with+TeamCity</a>.  For example </p>\n\n<pre><code>##teamcity[testSuiteStarted name=\'Test1\']\n</code></pre>\n\n<p>will let TeamCity know that a set of tests started.  With MbUnit you can\'t output these markers while the tests are running, but you can transform the XML file that it outputs.  Here is the XSL that I am using:</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;\n&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;\n    &lt;xsl:output method="text"/&gt;\n    &lt;xsl:template match="/"&gt;\n\n        &lt;xsl:apply-templates/&gt;\n\n    &lt;/xsl:template&gt;\n\n    &lt;xsl:template match="assemblies/assembly"&gt;\n##teamcity[testSuiteStarted name=\'&lt;xsl:value-of select="@name" /&gt;\']\n\n        &lt;xsl:apply-templates select="//run" /&gt;\n\n##teamcity[testSuiteFinished name=\'&lt;xsl:value-of select="@name" /&gt;\']\n    &lt;/xsl:template&gt;\n\n    &lt;xsl:template match="run"&gt;\n\n        &lt;xsl:choose&gt;\n            &lt;xsl:when test="@result=\'ignore\' or @result=\'skip\'"&gt;\n        ##teamcity[testIgnored name=\'&lt;xsl:value-of select="@name" /&gt;\' message=\'Test Ignored\']\n            &lt;/xsl:when&gt;\n            &lt;xsl:otherwise&gt;\n        ##teamcity[testStarted name=\'&lt;xsl:value-of select="@name" /&gt;\']\n            &lt;/xsl:otherwise&gt;\n        &lt;/xsl:choose&gt;\n\n\n        &lt;xsl:if test="@result=\'failure\'"&gt;\n            ##teamcity[testFailed name=\'&lt;xsl:value-of select="@name" /&gt;\' message=\'&lt;xsl:value-of select="child::node()/message"/&gt;\' details=\'&lt;xsl:value-of select="normalize-space(child::node()/stack-trace)"/&gt;\']\n        &lt;/xsl:if&gt;\n\n\n        &lt;xsl:if test="@result!=\'ignore\' and @result!=\'skip\'"&gt;\n        ##teamcity[testFinished name=\'&lt;xsl:value-of select="@name" /&gt;\']\n        &lt;/xsl:if&gt;\n\n    &lt;/xsl:template&gt;\n\n&lt;/xsl:stylesheet&gt;\n</code></pre>\n'}, {'answer_id': 30235, 'author': 'Scott Cowan', 'author_id': 253, 'author_profile': 'https://Stackoverflow.com/users/253', 'pm_score': 2, 'selected': False, 'text': '<p>Here\'s what I came up with</p>\n\n<p><strong>How can I merge in the test report?</strong></p>\n\n<p>First you\'ll need to get mbunit to generate both an XML and HTML report. The Command line arguments look like this</p>\n\n<pre><code>/rt:Xml /rt:Html /rnf:mbunit /rf:..\\reports\n</code></pre>\n\n<p>this will generate the reports into a dir called reports and the file will be called mbunit.xml and mbunit.html</p>\n\n<p>next we want to add these files as artifacts on the build</p>\n\n<pre><code>build\\reports\\* =&gt; Reports\n</code></pre>\n\n<p>the last step is to tell teamcity to add it as a tab for the build</p>\n\n<p>find the .BuildServer\\config\\main-config.xml and add this line\n(on windows this is in c:\\Documents and Settings\\, on linux it was in the /root dir)</p>\n\n<pre><code>&lt;report-tab title="Tests" basePath="Reports" startPage="mbunit.html" /&gt;\n</code></pre>\n\n<p><strong>How can I display "Tests failed: 1 (1 new), passed: 3049" for the build?</strong></p>\n\n<p>TeamCity looks for a file called teamcity-info.xml where you can stick messages in to be displayed. The Actual test count is actually just plain text. I think you can just add the file as an artifact but I\'ve also got it in the root dir of the build.</p>\n\n<p>in NAnt you\'ll want to use this command to do an XSLT on the MBUnit XML Report</p>\n\n<pre><code>&lt;style style="includes\\teamcity-info.xsl" in="reports\\mbunit.xml" out="..\\teamcity-info.xml" /&gt;\n</code></pre>\n\n<p>the actual xsl looks like this.\n(Note: that the { and } are reserved in xsl so we have to use params)</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;\n\n&lt;xsl:stylesheet version="1.0"\nxmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;\n&lt;xsl:param name="cbl" select="\'{\'"/&gt;\n&lt;xsl:param name="cbr" select="\'}\'"/&gt;\n&lt;xsl:template match="/"&gt;\n&lt;xsl:for-each select="report-result/counter"&gt;\n\n&lt;build number="1.0.{concat($cbl,\'build.number\',$cbr)}"&gt;\n    &lt;xsl:if test="@failure-count &amp;gt; 0"&gt;\n        &lt;statusInfo status="FAILURE"&gt;    \n            &lt;text action="append"&gt; Tests failed: &lt;xsl:value-of select="@failure-count"/&gt;, passed: &lt;xsl:value-of select="@success-count"/&gt;&lt;/text&gt;\n        &lt;/statusInfo&gt;\n    &lt;/xsl:if&gt;\n    &lt;xsl:if test="@failure-count = 0"&gt;\n        &lt;statusInfo status="SUCCESS"&gt;\n            &lt;text action="append"&gt; Tests passed: &lt;xsl:value-of select="@success-count"/&gt;&lt;/text&gt;\n        &lt;/statusInfo&gt;\n    &lt;/xsl:if&gt;\n\n&lt;/build&gt;\n&lt;/xsl:for-each&gt;\n\n&lt;/xsl:template&gt;\n&lt;/xsl:stylesheet&gt;\n</code></pre>\n\n<p>This will give you a file that looks like this</p>\n\n<pre><code>&lt;build number="1.0.{build.number}"&gt;\n   &lt;statusInfo status="FAILURE"&gt;\n      &lt;text action="append"&gt;Tests failed: 16, passed: 88&lt;/text&gt;\n   &lt;/statusInfo&gt;\n&lt;/build&gt;\n</code></pre>\n'}, {'answer_id': 880219, 'author': 'Mauricio Scheffer', 'author_id': 21239, 'author_profile': 'https://Stackoverflow.com/users/21239', 'pm_score': 4, 'selected': True, 'text': '<p><a href="http://blog.bits-in-motion.com/2008/10/announcing-gallio-and-mbunit-v304.html" rel="nofollow noreferrer">Gallio now has an extension</a> to output TeamCity service messages.\nJust use the included Gallio.NAntTasks.dll and enable the TeamCity extension. (this <a href="http://groups.google.com/group/gallio-dev/browse_thread/thread/812917adbca13d7b" rel="nofollow noreferrer">won\'t be necessary in the next release</a>)</p>\n'}, {'answer_id': 2246229, 'author': 'Sergey', 'author_id': 271242, 'author_profile': 'https://Stackoverflow.com/users/271242', 'pm_score': -1, 'selected': False, 'text': '<p>TeamCity Sidebar Gadget for Windows Vista, Windows 7 \n<a href="http://teamcity-gadget.com" rel="nofollow noreferrer">http://teamcity-gadget.com</a></p>\n'}]
['https://Stackoverflow.com/questions/3143', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/253/']