Publishing test results through command line test runner
Generally, a subset of tests are executed as part of a build as Build Verification Tests. You may want to run the full set of automated tests on a local machine and publish them to a TFS build. You can then get cumulative report of all tests run for that particular build. Alternately, you may have other standalone systems which execute automated tests as part of testing process. Now you can report results from these systems to a build.
TfsPublisher is a logger extension (see writing custom loggers for command line test runner) for Visual Studio 2012 Update 1 command line test runner, vstest.console.exe. It enables publishing test results from the command line to either on-premise or hosted TFS build. This capability allows publishing results from various sessions or machines to a single TFS build so that cumulative reports can be obtained for that build.
This blog briefs on the usage and options of the new logger – TfsPublisher. It’s installed at
“C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDECommonExtensionsMicrosoftTestWindowExtensionsMicrosoft.VisualStudio.TestPlatform.Extensions.TfsLogger.dll”
Collection=<team project collection URL>;
TeamProject=<team project name>
[;Platform=<Defaults to "Any CPU">]
[;Flavor=<Defaults to "Debug">]
Note: Optional parameters are wrapped with [ ]
Command line options:
· Collection : Team project collection URL.
· BuildName : Target build to publish test results against.
· TeamProject : Target team project.
· Platform : Optional build target platform (defaults to "Any CPU").
· Flavor : Optional build target flavor (defaults to "Debug").
· RunTitle : Name for the published results.
If Platform or Flavor is not specified, publishing would use default values. On successful publish, MTM URL of the published results is printed onto the console.
Published results report can be viewed in Microsoft Test Manager or through build reports from Visual Studio and Web access.
Publishing fails if either the default or user supplied values for Platform or Flavor doesn’t match with the target build and an appropriate error message is reported.
Test results can be published through TfsPublisher only for the current test run and publishing results from TRX files is not supported. If /EnableCodeCoverage switch is used, code coverage data is published along with the test results.
Following examples illustrates the usage of TfsPublisher logger from vstest.console.exe.
1. Publishing using defaults
# vstest.console.exe MyTest.dll /logger:TfsPublisher;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1
Published results can be viewed through the reported MTM URL: mtm://localhost:8080/tfs/DefaultCollection/p:MyProject/Testing/testrun/open?id=3
2. Publishing by supplying all parameters
# vstest.console.exe MyTest.dll /logger:TfsPublisher;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121129.2;Platform=x86;Flavor=Release;RunTitle="Project tests"
Here is how the published results appear from TFS web access build report.
3. Publishing with code coverage data (platform and flavor are left to defaults)
# vstest.console.exe MyTest.dll /logger:TfsPublisher;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121129.1;RunTitle="Project tests with code coverage data" /EnableCodeCoverage
Here is how the published results appear from Visual Studio 2012 build report.
Note: TfsPublisher requires Visual Studio 2012 Update 1. It’s compatible with Team Foundation Server 2012.
<p> </p> <p>This blog is from Shyam Prakash Velupula. Here is Shyam in his own words.</p> <p><font color="#0000ff">I am passionate about programming and reading tech stuff, currently a member of Visual Studio Product development team.</font></p>