3
votes

We're using TFS 2010 Team Build which automatically runs our unit tests during the build process. If I click on View Log, I can see the list of tests run and each test result (Success/Fail). In the event of Failure, I want to see the test result output (so the developer can figure out what the cause of the failure is). Just running the unit test locally isn't enough because the issue could be environmental (if the test is failing because of some data, server, or physical path).

How can I change my build process template to include the full results of the unit test in the log?

MSTest command line from View Log page:

e:\Program Files\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"E:\Builds\1\1\Sources\Source\TestSettings.testsettings" /searchpathroot:"E:\Builds\1\1\Binaries" /resultsfileroot:"E:\Builds\1\1\TestResults" /testcontainer:"E:\Builds\1\1\Sources\Source\Testing\bin\Release\Testing.dll" /publish:"http://tfs:8080/tfs/Projects" /publishbuild:"vstfs:///Build/Build/196" /teamproject:"Project" /platform:"Any CPU" /flavor:"Release" 

Screenshot of summary

http://imageshack.us/photo/my-images/28/tfsbuild.gif/

And of the Build Definition configuration

http://imageshack.us/photo/my-images/835/builddefinition.gif/

Thanks.

2
Please refine what you actually have & what you would like to achieve. What unit-testing framework are you using? Do you get the 'View Test Results' in the Summary View?pantelif
I'm using the built in mstest framework and activities that ship with TFS 2010 and are built in to the DefaultBuildProcessTemplate. I want the log of the build to include the full test result deatils for failed tests.Jeff

2 Answers

5
votes

If you use the default template and run the test using the unit test framework provided by Microsoft, you should be able to see a link to the published test results on the View Summary page of the build details. When you click at this link, the test results will be downloaded from the database and put together in an trx file that will be displayed in your Test Window in Visual Studio.

UPDATE: The problem was figured out after looking at the logs. The build template was customized to use another tool to build instead of MSBuild, and the summary nodes for each configuration (platform/flavor) were not created as a result. That's why the build details view was missing the summary, including the test results.

4
votes

There is one tiny, little detail that you need to know to get this to work. If you are using the web portal to view the test results for a build, You want to make sure that the Outcome column displays All (not just Failed). If all passed, nothing would be listed if the Outcome was set to Failed.

Here is a little picture of what I'm talking about: enter image description here

Notice how I have set the Outcome column to All. Now, if I select All as the Outcome, I can see all the tests listed. If you double-click any test the TFS web app will navigate you to the Run summary. Any tests that are linked with automation will have a Link provided to the Summary and any TRX files will be attached. Opening the TRX file will show the TestContext.WriteLine output, plus other data, like Duration.