The (Unofficial) ITWorx Technical Architecture Blog

MsTest working in CruiseControl.Net

Posted by archworx on June 6, 2007

I’ve trying to get MsTest, the unit tests generated by Visual Studio 2005, to work with cruise control for a while now. So finally I was able to get it to work following these steps below 

Let’s say we have a solution called ITT in the following path c:/ITT, first we’ll look at the ccnet config file, after you compile using the msbuild task, you have to call an exec task to execute the MsTests, but before that you have to delete the test results file because MsTest won’t run if the file is already there, we are doing this by calling a batch file to delete this test results file and also delete the temp folders created by MsTest. After that you have to merge the results file with build output so I can be displayed in the dashbaord.

 <project name=”ITT”>
      <intervalTrigger seconds=”100″ />

    <!– here you do the task to get the project from the source control –>
    <!–sourcecontrol type=”vss” autoGetSource=”true” applyLabel=”false”>

      <!– task to build the solution–> 
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>

        <!– call a batch file that deletes results.trx –>
        <!– this is required as MsTest will not create the file if it exists–>
        <!– the batch file also deletes the temp folders created by MsTest –> 
        <!– the exec task to execute the MsTest task –>
        <executable>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\MSTest.exe</executable>
        <buildArgs>/testcontainer:\ITT\AnalysisLibTests\bin\Debug\AnalysisLibTests.dll /runconfig:localtestrun.testrunconfig /resultsfile:results.trx</buildArgs>

      <!–to get the test results in the dashboard we have to merge the results XML file –>
      <xmllogger />
      <email from=”CruiseControl” mailhost=”mail” includeDetails=”TRUE”>


The next step is to modify the dashboard config file to display the test results, first we update the dashboard.config file to include the MsTests details menu item and then we add the MsTest results summary to the main build page. The required xsl files are already included with ccnet, you can customize the xsl to fit your needs

    <xslFile>xsl\MsTestSummary.xsl</xslFile> <!– MsTest results summary in main page–>
    <xslFile>xsl\unittests.xsl</xslFile> <!– Nunit test results, can be removed if not required any more –>
 <buildLogBuildPlugin />
   <xslReportBuildPlugin description=”NUnit Details” actionName=”NUnitDetailsBuildReport” xslFileName=”xsl\tests.xsl” />
   <xslReportBuildPlugin description=”NUnit Timings” actionName=”NUnitTimingsBuildReport” xslFileName=”xsl\timing.xsl” />
   <xslReportBuildPlugin description=”MSTest Report” actionName=”MSTESTReport” xslFileName=”xsl\MsTestReport.xsl”/> <!– menu item –>
   <xslReportBuildPlugin description=”NAnt Output” actionName=”NAntOutputBuildReport” xslFileName=”xsl\NAnt.xsl” />
   <xslReportBuildPlugin description=”NAnt Timings” actionName=”NAntTimingsBuildReport” xslFileName=”xsl\NAntTiming.xsl” />
   <xslReportBuildPlugin description=”FxCop Report” actionName=”FxCopBuildReport” xslFileName=”xsl\FxCopReport.xsl” />
   <xslReportBuildPlugin description=”NCover Report” actionName=”NCoverBuildReport” xslFileName=”xsl\NCover.xsl” />
   <xslReportBuildPlugin description=”Simian Report” actionName=”SimianBuildReport” xslFileName=”xsl\SimianReport.xsl”/> 

 That’s all


3 Responses to “MsTest working in CruiseControl.Net”

  1. Miguel said


    Thanks foy rour post. It was really a help for me.

    Have you ever tried to use MSTest of Visual Studio 2008. It seems that the xml generated in the test report is very different from the VS2005 version, and consequently the mstestsummary.xsl doesn’t show any results.

    I’ve tried to change the mstestsummary.xsl file, and i can now see the results. But my skills in xsl are not the best ones. Do you know if there is a XSL file for Visual Studio 2008 Test report?

    I’ve changed a few lines and i can now see the summary result.

    It will be very nice, if someone publish the xsl for visual studio 2008.

    Just my 2 cents.


  2. Asier said


    Have a look on this page:

    Chamindu has written the xsl files for visual studio 2008.


  3. apple said


    […]MsTest working in CruiseControl.Net « TechnicalArchitectureWorx[…]…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: