Click here to Skip to main content
14,664,780 members
Articles » General Programming » Programming Tips » Testing and Quality Assurance
Posted 17 Apr 2008


40 bookmarked

Integrating Visual Studio Team System 2008 Unit Tests with CruiseControl.NET

Rate this:
4.53 (23 votes)
Please Sign up or sign in to vote.
4.53 (23 votes)
17 Apr 2008CPOL
Explains how to integrate Visual Studio 2008 unit tests with the CCNET build process


Recently I had to work on a project that used VSTS unit tests and we needed to integrate the tests into our continuous integration process. We were using cruise control.NET. After doing a lot of research on the Web, I decided to write this small article since there is little information on the subject. This article assumes that you have already created a working continuous integration environment with CCNET for your Visual Studio 2008 project.

Executing the Unit Tests

You can use the command line test runner tool MSTest.exe to run your unit tests from CCNET. This requires that you install Visual Studio 2008 on the continuous integration server.

For example, the following command line can be used to execute the unit tests contained in the TestAssembly.dll and store the test results into results.xml.

MSTest.exe /testcontainer:TestAssembly.dll

One problem with MSTest is that it complains if the results file already exists. To avoid this, you have to delete the results file before calling MSTest. We can create a batch file in the projects working directory to do this, let’s call it RunTests.bat.

del results.xml
MSTest.exe /testcontainer:<PathtoTestProject>\Bin\Debug\TestAssembly.dll

You need to replace <PathToTestProject> with the absolute path of your unit test project and make sure the path to MSTest.exe is added to the system path. Everytime this batch file runs, it will delete the results.xml in the working directory and call MSTest that in turn will run the tests and create a new results file.

Now we need to call this batch file from CCNET. Open your ccnet.config file and insert an exec task just after the msbuild task that builds your project as given below:


Including the Results in the Build Report

First we need to merge the results.xml file to the build log. To do that, update the publishers section of the ccnet.config file as given below:


To include the unit test results in the build report, we need XSL files to generate the appropriate HTML. Unfortunately the XSL files supplied with CruiseControl as of version do not support the output format generated by MSTest version 9. I have created 2 XSL files called MSTest9Report.xsl and MSTest9Summary.xsl that are available in the download. These files are based on the MSTestReport.xsl and MSTestSummary.xsl distributed with CCNET version

Download and copy the files to the \CruiseControl.NET\server\xsl folder and \CruiseControl.NET\webdashboard\xsl folders. Then modify the ccservice.exe.config (or ccnet.exe.config if you use ccnet.exe instead of the ccservice) file by modifying the xslFiles section as given below:

    <file name="xsl\header.xsl"/>
    <file name="xsl\compile.xsl"/>
    <file name="xsl\mstest9summary.xsl"/>
    <file name="xsl\modifications.xsl"/>

In the above section, I have removed the unittests.xsl which is there by default and added mstest9summary.xsl instead.

Now we need to configure the Web dashboard. Open the dashboard.config file and update the buildPlugins section as given below:

      <buildLogBuildPlugin />

      <xslReportBuildPlugin description="MSTest Report" actionName="MSTESTReport" 


Again, I have removed the unittestsummary.xsl and added mstest9summary instead. The new xslReportBuildPlugin element causes a link to be displayed on the left side called “MSTest Report”, and when clicked it will display the detailed test results in a table.


That's it, now restart your ccservice and your VSTS unit tests should be fully integrated with cruise control. The XSL files supplied displays the Test Name, Outcome, Duration, Message and the Stack Trace but they can be easily modified to display additional information available in the test results.


  • 17th April, 2008: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Sri Lanka Sri Lanka
No Biography provided

Comments and Discussions

QuestionHelpful ! Question with vs 2012 Pin
usuariosapp22-Jul-14 8:50
Memberusuariosapp22-Jul-14 8:50 
Questionw VS 2010 Pin
StephenSalsero27-Jan-12 12:27
MemberStephenSalsero27-Jan-12 12:27 
AnswerRe: w VS 2010 Pin
StephenSalsero30-Jan-12 16:03
MemberStephenSalsero30-Jan-12 16:03 
GeneralNUnit and MsTests on the same CruiseControl Pin
ABlokha7718-Feb-11 2:39
MemberABlokha7718-Feb-11 2:39 
GeneralRe: NUnit and MsTests on the same CruiseControl Pin
chamindu19-Feb-11 2:38
Memberchamindu19-Feb-11 2:38 
GeneralGREAT! Pin
Michel.Net17-Sep-10 4:08
MemberMichel.Net17-Sep-10 4:08 
GeneralRe: GREAT! Pin
Michel.Net17-Sep-10 4:09
MemberMichel.Net17-Sep-10 4:09 
GeneralRe: GREAT! Pin
chamindu20-Sep-10 19:06
Memberchamindu20-Sep-10 19:06 
GeneralGood Pin
AlanLiuhua10-Feb-10 22:28
MemberAlanLiuhua10-Feb-10 22:28 
GeneralTop Article! Pin
KazMaxLtd8-Jan-10 2:59
MemberKazMaxLtd8-Jan-10 2:59 
GeneralRe: Top Article! Pin
chamindu20-Sep-10 19:07
Memberchamindu20-Sep-10 19:07 
Generalvery good Pin
Donsw3-May-09 16:39
MemberDonsw3-May-09 16:39 
QuestionVery Cool Pin
novocaine16-Apr-09 12:39
Membernovocaine16-Apr-09 12:39 
GeneralIssue with CruiseControl WebDashboard Pin
jaanuforabdi30-Dec-08 3:12
Memberjaanuforabdi30-Dec-08 3:12 
GeneralConfiguring Multiple VSTS Test Projects for Reporting in CruiseControl.NET Pin
skingaby20-Aug-08 12:54
Memberskingaby20-Aug-08 12:54 
GeneralRe: Configuring Multiple VSTS Test Projects for Reporting in CruiseControl.NET Pin
bflecht23-Feb-09 4:24
Memberbflecht23-Feb-09 4:24 
GeneralRe: Configuring Multiple VSTS Test Projects for Reporting in CruiseControl.NET Pin
KazMaxLtd9-Jan-10 0:31
MemberKazMaxLtd9-Jan-10 0:31 
GeneralRe: Configuring Multiple VSTS Test Projects for Reporting in CruiseControl.NET Pin
KazMaxLtd9-Jan-10 0:44
MemberKazMaxLtd9-Jan-10 0:44 
GeneralVery helpful Pin
Paul VR12-Aug-08 13:58
MemberPaul VR12-Aug-08 13:58 
Questionwill this work for VS2005 as well? Pin
MJJT25-Jul-08 13:41
MemberMJJT25-Jul-08 13:41 
GeneralJust What the Dr. Ordered Pin
BrowniePoints14-Jul-08 18:37
MemberBrowniePoints14-Jul-08 18:37 
GeneralRe: Just What the Dr. Ordered Pin
chamindu14-Jul-08 20:20
Memberchamindu14-Jul-08 20:20 
QuestionReference to MsTest9Report.xsl instead of MsTestReport.xsl? Pin
Milzit14-Jul-08 17:07
MemberMilzit14-Jul-08 17:07 
AnswerRe: Reference to MsTest9Report.xsl instead of MsTestReport.xsl? Pin
chamindu14-Jul-08 20:20
Memberchamindu14-Jul-08 20:20 
GeneralRe: Reference to MsTest9Report.xsl instead of MsTestReport.xsl? Pin
Milzit15-Jul-08 6:51
MemberMilzit15-Jul-08 6:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.