blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Stuart Preston's Blog

Mostly about Visual Studio Team System, Team Foundation Server, Engineering Practices and Application Lifecycle Management.

Team Build: Extending Team Build to show Unit Test failures in the summary page.

As those who are doing unit testing in Visual Studio Team System will know, it is not always the easiest thing to access the Test Run results after a build.  You have to expand the Result Details panel, click on the test results file and select a location on your local machine to download the results to before they can be opened in Visual Studio again.  For some people this is a good enough reason to use CruiseControl.NET.

To provide a workaround to those who wish to stay purely in the Visual Studio environment, I have written (well glued, technically) a simple solution in the form of a custom task for Team Build that displays any failing tests directly in the "Build steps" panel.  I cannot take the credit for the bulk of the code that inserts the messages into the panel which is a modified version of the example on Aaron Hallberg's blog: http://blogs.msdn.com/aaronhallberg/archive/2006/08/29/adding-buildsteps-to-team-build-through-a-custom-task.aspx.  The rest of the code simply spins through the Test Results folder (as available in each Team Build by the $(TestResultsRoot) variable) and then grabs the UnitTestResult messages and stack trace from each .trx (Test Result file) that it finds, writing each line to its own build step.

This means we can now get output such as the below, indicating the cause of a failure immediately:

Deployment of the custom task is a fairly simple process.  If you want to make the change globally to a Team Build server, simply drop the attached assembly into “%ProgramFiles%\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild” and customise the Microsoft.TeamFoundation.Build.targets file in the same folder to include the following:

At the top with all the other "UsingTask" elements:

  <UsingTask TaskName="UnitTestFailureParser" AssemblyFile="Conchango.TeamBuild.Tasks.UnitTestFailureParser.dll" />

Then replace the "AfterTest" target with:

  <Target Name="AfterTest">
          <UnitTestFailureParser
                  TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                  BuildUri="$(BuildUri)"
                  TestResultsRoot="$(TestResultsRoot)" />
  </Target>

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

TrackBack said:

June 14, 2007 08:03
 

TrackBack said:

June 14, 2007 08:03
 

TrackBack said:

Manual trackback to http://widgets.accentient.com/
June 20, 2007 13:19
 

Michael Freitag said:

This is really a great feature. But I have the problem that the task seems to get the information from old test results sometimes. Even if the build and all tests have run without any problems the FailureParser writes some error informations to the email, and this information belongs to older builds. Is it a problem if the testresults of all builds which have run up to now are in the same directory?
June 22, 2007 14:56
 

Stuart.Preston said:

How old are the results?  By default I believed the build results go into the temporary workspace set up by Team Build, so they should only be as old as the beginning of the build.  Can you eloborate on how you are using it?  Are you overriding the $(TestResultsRoot) variable somewhere and perhaps that folder needs to be cleaned out first before you do a build?  You could add the /v:diag parameter to your TFSBuild.rsp file to generate some more verbose debugging.

June 22, 2007 15:23

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems