Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Adding MSTest results (.trx) files to your TeamCity build results

As I am building out our CI environment with TeamCity (man, this is a great product) I finally had to tackle something that I have been putting off for the past few weeks.  Adding the tests results to TeamCity from our various components which use MSTest.  I have already added NUnit results, as that is done for you out of the box with TeamCity.  Now before you ask ‘Why are you using both MSTest and NUnit’?  We simple.  Most our older tests are done with MSTest (god, I really, really hate MSTests – More here) and most our newer (less than 6 months old) code is in NUnit.

I really thought that adding MSTests would be a pain, but as it turned out it was not.  I searched Jetbrains knowledge base and found this posting which talked about what  you needed to do to add MSTest results to your build.

Basically you only need to add this line to your build (assuming NAnt here) file.

##teamcity[importData id='mstest' file='<path to .trx file>']

When I say add it, I simply mean doing a echo of this information.  This is possible because TeamCity watches the standard output stream for various commands, and this is one of the commands you can use.

Here is how I added this to my build file:

<target name="tests.run.HL7" >
  <property name="test.resultFile.name" value="${tests.output.dir}/testResults.trx" />
  <if test="${file::exists(test.resultFile.name)}">
    <echo message="Deleting old test run file ${test.resultFile.name}" />
    <delete file="${test.resultFile.name}" />
  </if>
  <exec program="MSTest.exe"
        commandline="/testcontainer:${build.dir}${communication.tests.file} /testcontainer:${build.dir}${httpImportService.tests.file} /testcontainer:${build.dir}${messagesCore.tests.file} /testcontainer:${build.dir}${messageHandler.tests.file} /resultsfile:${tests.output.dir}/testResults.trx"
        basedir="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE"
        failonerror="false"
        />

  <!--- This is the needed line for TeamCity -->
  <echo message="##teamcity[importData id='mstest' file='…path to output….\Output_AutomatedBuild\Output_UnitTests\testResults.trx']" />
</target>

As you can see this is real easy.  Once you have this in your build file simply re-run your build in TeamCity and check your build results.  If you did every thing correct you should have a ‘Test’ tab.  If something went wrong check your output logs as it should tell you what blew up.

Hope this helps someone.

Till next time,

[--- Check out www.Dimecasts.net ---]


Posted 12-20-2008 9:39 AM by Derik Whittaker

[Advertisement]

Comments

Dew Drop - Weekend Edition - December 20-21, 2008 | Alvin Ashcraft's Morning Dew wrote Dew Drop - Weekend Edition - December 20-21, 2008 | Alvin Ashcraft's Morning Dew
on 12-20-2008 9:08 PM

Pingback from  Dew Drop - Weekend Edition - December 20-21, 2008 | Alvin Ashcraft's Morning Dew

DotNetKicks.com wrote Simple how to on adding MSTest results files to TeamCIty
on 12-21-2008 9:25 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)