Go to content Go to navigation Go to search

Brokenwire.NET::Programming

Publishing test results to TFS
· 2008-02-28 09:06 by Thijs Kroesbergen for Brokenwire.NET

When running (unit-)tests outside your build process it is still possible to publish the test results back to the build you're testing. For this you can use MsTest.exe or Visual Studio and you need the Team Explorer bits installed. Because we implemented a fully automated system-integration testing system we wanted to use the command line to start the tests and have the results published back to TFS.

So, straight from the MsTest /?:

The following options are also available if Team Explorer is installed: /publish:[server name] Publish results to the Team Foundation Server. /publishbuild:[build name] The build identifier to be used to publish test results. /publishresultsfile:[file name] The name of the test results file to publish. If none is specified, use the file produced by the current test run. /teamproject:[team project name] The name of the team project to which the build belongs. Specify this when publishing test results. /platform:[platform] The platform of the build against which to publish test results. /flavor:[flavor] The flavor of the build against which to publish test results.

That's easy! Yes, but, hmm not so easy after all....

Here is the catch (which took me a lot of time to figure out): You need to specify the value for the platform parameter exactly the same as you have it defined in your build! Our build is configured with "Any CPU" but when passing "x86" seemed to work as well, except that the results would just disappear. This is what happened: when passing the wrong platform MsTest will publish your results to TFS, but you can not find them ever again! When you pass the correct parameters the results will be attached to the build tested (and they are visible in the build store) and results file (.trx) will be placed in the drop location for that build.

The 4 possibilities for platform are:

A full example of using the MsTest.exe command to kick the test and publish the results to TFS:

MSTest /nologo /testcontainer:"MyTests.dll" /runconfig:"localtestrun.testrunconfig" /resultsfile:"MyTestResults.trx" /test:MyUnitTest /publish:"http://TfsServer:8080" /publishbuild:"DailyTestBuild_20080227.1" /teamproject:"TestProject" /platform:"Any CPU" /flavor:Debug

Now if MsTest (or the TFS webservice) would just have returned an error if you passed in the wrong platform, that would have been much better (and saved me a lot of time)...

Permalink -