|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionRecently 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 TestsYou 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
/resultsfile:results.xml
One problem with del results.xml
MSTest.exe /testcontainer:<PathtoTestProject>\Bin\Debug\TestAssembly.dll
/resultsfile:results.xml
You need to replace Now we need to call this batch file from CCNET. Open your ccnet.config file and insert an <tasks>
<msbuild>...</msbuild>
<exec>
<executable>{WorkingDirectory}\RunTests.bat</executable>
<baseDirectory>{WorkingDirectory}</baseDirectory>
</exec>
</tasks>
Including the Results in the Build ReportFirst 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: <publishers>
<merge>
<files>
<file>{WorkingDirectory}\results.xml</file>
</files>
</merge>
...
</publishers>
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 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>
<file name="xsl\header.xsl"/>
<file name="xsl\compile.xsl"/>
<file name="xsl\mstest9summary.xsl"/>
<file name="xsl\modifications.xsl"/>
</xslFiles>
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>
<buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\header.xsl</xslFile>
<xslFile>xsl\modifications.xsl</xslFile>
<xslFile>xsl\compile.xsl</xslFile>
<xslFile>xsl\MsTest9Summary.xsl</xslFile>
<xslFile>xsl\fxcop-summary.xsl</xslFile>
<xslFile>xsl\NCoverSummary.xsl</xslFile>
<xslFile>xsl\SimianSummary.xsl</xslFile>
<xslFile>xsl\fitnesse.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<buildLogBuildPlugin />
<xslReportBuildPlugin description="MSTest Report" actionName="MSTESTReport"
xslFileName="xsl\MsTestReport.xsl"/>
Again, I have removed the unittestsummary.xsl and added ConclusionThat'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. History
|
||||||||||||||||||||||