Getting MSTest output to show in CruiseControl.Net - cruisecontrol.net

I currently have our build server set up with CruiseControl.Net running a build using MSBuild and then running unit tests using MSTest. The problem is I can't see the output of the unit tests in CC - I know they are being run because I can get the build to fail if I commit a failing test.
I have followed the online guides from http://blogs.blackmarble.co.uk/blogs/bm-bloggers/archive/2006/06/14/5255.aspx and http://www.softwarepassion.com/?p=89 but still having no luck.
My ccnet.config file contains
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\CCBuilds</workingDirectory>
<projectFile>Application.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
<exec>
<executable>deleteTestLog.bat</executable>
<baseDirectory>C:\CCBuilds</baseDirectory>
<buildArgs></buildArgs>
<buildTimeoutSeconds>30</buildTimeoutSeconds>
</exec>
<exec>
<executable>C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>C:\CCBuilds</baseDirectory>
<buildArgs>/testcontainer:UnitTests\bin\Debug\UnitTests.dll /runconfig:localtestrun.Testrunconfig /resultsfile:testResults.trx</buildArgs>
<buildTimeoutSeconds>30</buildTimeoutSeconds>
</exec>
</tasks>
<publishers>
<merge>
<files>
<file>testResults.trx</file>
</files>
</merge>
<xmllogger logDir="C:\Program Files\CruiseControl.NET\server\Checkin Build\Artifacts\buildlogs" />
</publishers>
The log file in C:\Program Files\CruiseControl.NET\server\Checkin Build\Artifacts\buildlogs contains the unit test results, have I missed any steps?

i made the following changes to get MSTest results output to be shown in CruiseControl.NET
1) For Dashboard - in dashboard.config added a reference to the Mstest 2008 xsl file under buildReportBuildPlugin
<xslFile>xsl\MsTestReport2008.xsl</xslFile>
2) For email - in ccservice.exe.config added the reference to the same xsl file under xslFiles section
<file name="xsl\MsTestSummary2008.xsl"/>

Did you configure your web dashboard with the correct xsl to format the outputs? There are two different versions of the XSL's (Summary and Report) for VSTS 2005 and 2008 as Microsoft changed the XML output drastically between the two versions. The changes were very good, just breaking changes.

For the Dashboard, I think you need to add the MSTest Summary in the xlsFiles, but add the MSTest Report build report plugin. That is,
<buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\MsTestSummary2008.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<xslReportBuildPlugin description="MSTest Report" actionName="MSTESTReport" xslFileName="xsl\MsTestReport2008.xsl" />
</buildPlugins>
I tried adding MSTestReport on both but it didn't work, but the setting above did. Hope that helps...

Related

How to integrate xUnit.net with CruiseControl.net

I have a continuous integration server that discovers and runs assemblies with NUnit tests. I would like to add some assemblies with xUnit.net tests to the mix. How would I do that?
Download xunit-build-xyzw.zip from xUnit.net on CodePlex and extract it to, for example, C:\Program Files\xUnit.net. Add this location to PATH environment variable
be sure to have no trailing semicolon
Modify your CC.NET *.build script to discover assemblies by convention, as outlined below
note that command line argument syntax no longer has equals sign
In C:\Program Files\CruiseControl.NET\server\ccnet.config, Merge XML files produced by NUnit runner and by xUnit.net runner, as outlined below
merging happens after build, irrespective of build status
be sure results of test run get deleted in the beginning of build script
Restart CC.NET
Download xUnitSummary.xsl from xUnit.net on GitHub and place it in C:\Program Files (x86)\CruiseControl.NET\WebDashboard\xsl
In C:\Program Files\CruiseControl.NET\WebDashboard\dashboard.config, modify buildPlugins element as outlined below
Restart IIS
Additional info:
CruiseControl.Net – Server Installation at Neal's Blog
Step 2:
<project default="RunTests_xUnit">
<target name="RunTests_xUnit" description="Runs the discovered xUnit.net unit tests" depends="someCompileStep">
<!-- Outer loop to search through a list of different locations -->
<!-- Folders to be searched should listed as a semicolon deliminated list in the 'in' attribute -->
<foreach item="String" in="${TestAssemblyOutputPath}" delim=" ;" property="testsPath">
<echo message="Searching for xUnit.net test suites in ${testsPath}" />
<!-- Inner loop to search for dlls containing unit tests -->
<foreach item="File" property="filename">
<in>
<items basedir="${testsPath}">
<!-- see http://nant.sourceforge.net/release/0.91/help/types/fileset.html for how to include or exclude specific files or file patterns -->
<!-- attempt to run tests in any dlls whose name ends with UnitTestSuite.dll' -->
<include name="**UnitTestSuite.dll" />
</items>
</in>
<do>
<property name="testDLLName" value="${path::get-file-name-without-extension(filename)}" />
<echo message="Testing ${testDLLName} with xUnit.net" />
<exec program="${xunit-console.exe}" failonerror="true" resultproperty="resultVal">
<arg line="${testsPath}\${testDLLName}.dll /xml ${xUnitTestLogsFolder}${testDLLName}-xUnitResults.xml" />
</exec>
<fail message="Failures reported in ${testDLLName}." failonerror="true" unless="${int::parse(resultVal)==0}" />
</do>
</foreach>
</foreach>
</target>
</project>
Step 3:
<publishers>
<merge>
<files>
<file>C:\logs-location\xUnitTestLogs\*UnitTestSuite-xUnitResults.xml</file>
<file>C:\logs-location\TestLogs\*Tests-Results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
</publishers>
Step 5:
<buildPlugins>
<buildReportBuildPlugin>
<xslFileNames>
...
<xslFile>xsl\xUnitSummary.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
...
<xslReportBuildPlugin description="xUnit.net Report" actionName="xUnitReport" xslFileName="xsl\xUnitSummary.xsl" />
...
</buildPlugins>

Multi Projects with CCNET

I have GIT repo as below,
\main
\Module A
\Module B
\Shared
When i make a change on Module B, CCNET will make a build from Module A and then Module B,
I dont want CCNET to do this way.It will take a lot of time.
I just want ccnet build only changes on Module B.
Somebody please help me :
My 1 project in CCNET Config:
enter code here
<project name="Dashboard 5.0" queue="Dashboard_01" queuePriority="01" category="01">
<artifactDirectory>&pathToArtifactsDirectory;Dashboard 5.0\</artifactDirectory>
&workingDirectory;
<webURL>http://&buildServerAddress;/ccnet/server/&buildServerName;/project/Dashboard 5.0/ViewLatestBuildReport.aspx</webURL>
&modificationDelaySeconds;
<triggers>
<intervalTrigger seconds='30' buildCondition='IfModificationExists'/>
<scheduleTrigger time='03:00' buildCondition='ForceBuild' name='Scheduled'/>
<scheduleTrigger time='11:00' buildCondition='ForceBuild' name='Scheduled'/>
</triggers>
<state type="state" directory="&pathToStatesDirectory;Dashboard 5.0\" />
<sourcecontrol type="git">
<repository>&gitAddress;</repository>
<branch>master</branch>
<autoGetSource>true</autoGetSource>
<fetchSubmodules>false</fetchSubmodules>
<executable>C:\Program Files (x86)\Git\cmd\git.exe</executable>
<commitBuildModifications>false</commitBuildModifications>
<commitUntrackedFiles>false</commitUntrackedFiles>
<timeout>3000000</timeout>
</sourcecontrol>
<tasks>
<nant>
<executable>&pathToNantFile;</executable>
<baseDirectory>&pathToBuildScriptsDirectory;Dashboard 5.0\</baseDirectory>
<buildArgs>-D:projects_to_build=dashboard_framework</buildArgs>
<buildFile>cruise.build</buildFile>
<targetList>
<target>automate</target>
</targetList>
<buildTimeoutSeconds>3000</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\*Test.dll-results.xml</file>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\Test*.dll-results.xml</file>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\simian.xml</file>
</files>
</merge>
<xmllogger />
</publishers>
Any check in for Module A or Module B will cause the project node to start either way. What you are looking for is similar to what subversion update command on a sub folder does and Git is not intended to be this way. An alternative you can create a separate repository for each module. The build script or Nant task would have to be separated as well.
In Git, if you have several directories that are always checked out independently, then these are really two different projects and should live in two different repositories. You can merge them back together at a later point using Git Submodules

Need help integrating NCover 3.4 into CruiseControl.Net 1.5 with xUnit 1.6.1

I'm trying to integrate NCover into my CC.net build. I followed an article I found here http://csut017.wordpress.com/2009/05/29/improved-ncover-integration/ that I pretty much followed verbatim except that we use xUnit instead of nUnit for our unit tests. The problem is NCover never runs on the build server with this configuration and I was wondering if anyone else had some experience with this and could give me some advice.
Below is the pertinent parts of my ccnet.config file. The <msbuild> portion of the config is running our unit tests which have been configured right in the proj files.
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe</executable>
<workingDirectory>c:\projects\win_wip\src\Core.Tests</workingDirectory>
<projectFile>Core.Tests.csproj</projectFile>
<buildArgs>/noconsolelogger /p:configuration=debug</buildArgs>
<targets>Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
<ncoverProfile>
<executable>c:\program files\ncover\ncover.console.exe</executable>
<program>C:\Projects\win_wip\lib\xunit-1.6.1\xunit.console.clr4.x86.exe</program>
<testProject>DomainModel.Tests.dll</testProject>
<workingDir>c:\projects\win_wip\src\domainmodel.tests\bin\debug</workingDir>
<includedAssemblies>domainmodel.*.dll</includedAssemblies>
</ncoverProfile>
<ncoverReport>
<executable>C:\Program Files\NCover\NCover.Reporting.exe</executable>
<outputDir>ncover\reports</outputDir>
<reports>
<report>FullCoverageReport</report>
</reports>
<sortBy>CoveragePercentageDescending</sortBy>
</ncoverReport>
Have you tried the documentation at http://docs.ncover.com/how-to/continuous-integration/cruisecontrol-net/?

CruiseControl.Net build logs not showing on CCNet website after upgrade

We've been using CruiseControl.Net for a couple of years now and it has been working fine. However, since our last upgrade a few weeks ago to the latest version (1.5.0.6237) our build reports are failing to display on the ccnet website. Instead we get the following message:
"BUILD FAILED
Project: TX
Date of build: 2010-06-22 23:41:54
Running time: 00:05:06
Integration Request: Build (ForceBuild) triggered from ScheduleTrigger
Last changed: 2010-06-22 15:14:14
Last log entry: Merge Branches:
Origin=$/Source/RE/Branches/3.1
Version: 2629 [DT- 3652]: Reporting:
Capture tradable duration seperately
Modifications since last build (10)
Checked in Donald.sutherland Trunk/SLP/SLPDatabase/CreateScripts/CreateReportDataStoreTables.sql
Merge Branches: Origin=$/Source/RE/Branches/3.1
Version: 2629 [DT-3652]: Reporting:
Capture tradable duration seperately
2010-06-22 15:14:14
Checked in Donald.sutherland Trunk/SLP/SLPDatabase/Change Scripts/ReportDataStore/RpDataStoreDatabaseChangeScript.sql
Merge Branches: Origin=$/Source/RE/Branches/3.1
Version: 2629 [DT-3652]: Reporting:
Capture tradable duration seperate
What should follow is a number of error messsages indicating why the build has failed. The webpage that is failing to parse the log file is "ViewBuildReport.aspx". In order to get an explanation, our development team has to go through the full Build Log xml and search for failures.
The build.config file is attached below:
<project name="TX" queue="Build" queuePriority="1400">
<triggers>
<scheduleTrigger time="21:00" buildCondition="ForceBuild">
<weekDays>
<weekDay>Monday</weekDay>
<weekDay>Tuesday</weekDay>
<weekDay>Wednesday</weekDay>
<weekDay>Thursday</weekDay>
<weekDay>Friday</weekDay>
<weekDay>Saturday</weekDay>
<weekDay>Sunday</weekDay>
</weekDays>
</scheduleTrigger>
</triggers>
<sourcecontrol type="vault" autoGetSource="true" applyLabel="false">
<executable>c:\program files\sourcegear\vault client\vault.exe</executable>
<username>build</username>
<password>*********</password>
<host>niddrie.dataexplorers.net:8080</host>
<repository>DXL Source</repository>
<folder>$/Source/TX/Trunk</folder>
<ssl>false</ssl>
<useWorkingDirectory>true</useWorkingDirectory>
<workingDirectory>D:\Projects\Source\TX\Trunk</workingDirectory>
<cleanCopy>true</cleanCopy>
<timeout units="minutes">30</timeout>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>D:\Projects\Source\TX\Trunk</workingDirectory>
<projectFile>TransactionExplorer.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Release /v:diag</buildArgs>
<targets>Build</targets>
<timeout>600</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
</msbuild>
<exec>
<executable>deploy.bat</executable>
<baseDirectory>D:\Projects\Source\TX\Trunk</baseDirectory>
<buildArgs>D:\Projects\Source\TX\Trunk D:\MasterWebsite\SfsWebroot\Autobuild\TX</buildArgs>
<buildTimeoutSeconds>500</buildTimeoutSeconds>
</exec>
</tasks>
<publishers>
<!-- Mandatory, config file does not work without -->
<xmllogger logDir="C:\Program Files\CruiseControl.NET\server\TX\Artifacts\buildlogs" />
&email;
</publishers>
</project>
As you can see, there is a publisher and the config file hasn't changed since we upgraded to the latest CruiseControl Version. Finally, the necessary log files get generated during the build so it seems to be an issue with the xsd parse or the website itself? The build result files generated are listed below:
C:\Program Files\CruiseControl.NET\server\TX\Artifacts\msbuild-results.xml
C:\Program Files\CruiseControl.NET\server\TX\Artifacts\buildlogs\log20100622234154.xml
Any help to get this working will be greatly appreciated.
Did you check your email publisher? There have been a breaking change with CCNET 1.5. You can read more here :
http://ccnetlive.thoughtworks.com/ccnet/doc/CCNET/CCNet%201.5%20CTP%20Release%20Notes.html
http://ccnetlive.thoughtworks.com/ccnet/doc/CCNET/Email%20Publisher.html
If I understood you well, you said that your build worked fine but since you upgraded it fails, isn't it? How did you do the upgrade? Did you change directory/rights?

CruiseControl.NET post-build actions

We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application.
The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference is specific config files and so on - so I want to exclude some files - or delete them before the pre-compiled app is copied to a network share.
My config file looks like this:
<project name="Assembly.Web.project">
<triggers>
<intervalTrigger seconds="3600" />
</triggers>
<sourcecontrol type="svn">
<trunkUrl>svn://svn-server/MyApp/Web/Trunk</trunkUrl>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<executable>C:\Program Files (x86)\SVN 1.5 bin\svn.exe</executable>
<username>uid</username>
<password>pwd</password>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<projectFile>C:\build-server\Assembly\Web\TEST-HL\Web\Web.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
<publishers>
<buildpublisher>
<sourceDir>C:\build-server\Assembly\Web\PrecompiledWeb</sourceDir>
<publishDir>\\test-web01\Web</publishDir>
<useLabelSubDirectory>false</useLabelSubDirectory>
<alwaysPublish>false</alwaysPublish>
</buildpublisher>
</publishers>
</project>
As you can see, I use a buildPublisher to copy the pre-compiled files to the network share. What I want to do here, is either 1) delete certain files before they are copied or 2) replace those files after they have been copied.
I DO NOT want to have some app running watching specific files for change, and then after that replace the files with other ones. I want something to be either done by CC.NET, or triggered by CC.NET.
Can you launch a .bat file with CC.NET?
I use a NAnt task for all publishing, deploying, cleaning and so on.
Take a look at MSDEPLOY or Web Deployment Projects. There is a question that will provide more detail here
You have to use NAnt for those kind of stuff.
Here is the Task Reference of Nant..
Of course CruiseControl.NET can run a batch file, simply use the exec task. However, an easier answer might just be to have MSBuild do the task for you. It should be simple to add a few steps in the postcompile target.

Resources