ENTERPRISE

Visual Studio Team System 2008 : Command Line (part 2)

9/26/2012 1:27:40 AM

Publishing test results

This option&; is valid only if we have the Team explorer installed, and if the Visual Studio is connected to the Team Foundation Server (TFS). This publishes the test data and results to the TFS team project. Please refer to MSDN for more information on installing and configuring TFS and Team explorer.

Using the command line utility and the various options, we can publish the test run results. The publish option with MSTest will first run the test and then set the flavor and platform for the test before publishing the data to the TFS. Some of these options are mandatory for publishing the test run details.

We will see the examples of different publishing options available for the command line MSTest tool.

/publish

The /publis&;h command should be followed by the URI of the TFS if the TFS is not registered in the client. If it is registered, we can use just the name of the server to which the test result has to be published.

/publish:[server name]

Example 1: /publish:http://MyTFSServer

(If the TFS Server is not registered in the client)

Example 2: /publish:MyTFSServer

(If the TFS Server is registered with the client)

/publishbuild

This option&; is used for specifying the build name for publishing. This is the unique name that identifies the build from the list of scheduled builds.

/flavor

This is a m&;andatory option for publishing the test results to the TFS. Flavor is a string value which should be used in combination with the platform name and should match with the completed build that can be identified by the /publishbuild option. Before publishing the test run results to the TFS, MSTest will run the test and then set the flavor and the platform properties.

/flavor:[flavor

Examples 1: /flavor:Release

Example 2: /flavor:Debug

/platform

This is a m&;andatory string value used in combination with the /flavor option which should match the build option.

/platform:[string value]

Example 1: /platform:Mixed Platforms

Example 1: /platform:.NET

Example 1: /platform:Win32

/publishresultsfile

MSTest stor&;es all test results in default trace files with the extension .trx. Using this /publishresultsfile option we can publish the test results output/trace file to the TFS. The name of the file is the input to this option. If the value is not specified, MSTest will publish the current test run trace file to TFS.

/publishresultfile:[file name string]

Example 1: /publishresultfile

(current test run trace file will be published)

Example 2: /publishresultfile:

Trace files

Before publ&;ishing the test result we have to store the test results in a trace file. Use the /tracefile option with the MSTest command line to store the test results. The default extension for the trace file is trx. It is better to use the same extension when we force the Visual Studio to use a specific trace file for the test results.

For example:

MSTest /testmetadata:TestProject.vsmdi /testfile:TestProject.trx

Publishing

To publish the test result, we can use a combination of the different options seen above, and the only option is /publishresultsfile.

Let us try creating a trace file and then create a build type for the project. Then we can publish the test result trace file to the build.

Step 1: Create test project

The followi&;ng image contains the solution ClassLibrary1. The solution contains a simple class library project ClassLibrary1. Use the menu option, Test | New Test from the Visual Studio IDE and then choose the unit test type. Name the test and select the existing project or choose the option to create a new project to add the new test. The following image shows the test project named ClassLibrary1TestProject.

Step 2: Running the test

The test pro&;ject ClassLibrary1TestProject contains two unit test methods. Run the test and by default, the test result is stored in the trace files<file name>.trx.

Step 3: Create Build

Now is the ti&;me to create the build type for the team project. The steps and the details behind creating the build types are out of the scope of this book. So let us do an overview on how to create the build type using the Team Explorer. Within the Team Explorer, select the Build definitions under the Builds option folder, which is under the team project. Right-click and choose a new build definition and configure the options by choosing the projects in TFS and the local folder. In one of the steps, you can see the following screenshot for selecting the project and setting the configuration information for the build.

The following scree&;nshot shows the important configuration setting required for build, which should match the test results publishing parameters: the platform and the flavor values:

Step 4: Build Project

Now we have cre&;ated all the projects and set the configurations and properties. We are ready to run the test, build and publish the test results. Select the new build and run it. You can notice the Build name for the current build. The Build steps show the platform and the flavor used for building the solution. The result details section shows no test results as we do not have any test results published yet.

Step 5: Publish Result

So far we have c&;reated the test results file and also built the projects. All the test runs were successful in which the test failed. Now is the time to publish the test results to the build. We have seen the options used for publishing the test results using the MSTest command line. The following command publishes the two test results to the build specified:

The command line options used in the above picture shows the test result trace file used for publishing. The command line also has the platform and the flavor values matching the build configurations set in step 3 above. The publishing is done using the web service shown previously. There are different methods exposed by the web service.

After publishing&; the test results, if you open the build NewBuild_20081029.2, you can see the test information as shown in the following image, which is nothing but information from the trace file.

The test URL will open the page which shows all the details of the test run. You can publish any number of test results to the TFS and bind it to a particular build so that the test results correspond to that particular build.

Other  
  •  System Center Configuration Manager 2007 : Configuration Manager Network Communications (part 4) - Site-to-Site Communications - Tuning Status Message Replication
  •  System Center Configuration Manager 2007 : Configuration Manager Network Communications (part 3) - Site-to-Site Communications - Configuring Senders, Configuring Sender Addresses
  •  System Center Configuration Manager 2007 : Configuration Manager Network Communications (part 2) - Client-to-Server Communications
  •  System Center Configuration Manager 2007 : Configuration Manager Network Communications (part 1) - Intrasite Server Communications
  •  External Drive Western Digital My Book Thunderbolt Duo
  •  IP Camera Eyespy247 EXT+ - Cloud-Based Home And Office Video-Monitoring System
  •  Set-Top Box Philips HMP2000
  •  A Partnership Fizzles
  •  Microsoft Dynamics AX 2009 : Building Lookups - Building a tree lookup
  •  Microsoft Dynamics AX 2009 : Building Lookups - Using a form for lookup building
  •  
    Most View
    Top 10 Web Log Analysers (Part 1)
    No Sound Left Behind
    Windows Server 2008 and Windows Vista : Item-Level Targeting (part 7) - Item-Level Targeting Controls, Common Item-Level Targeting Scenarios
    Appleā€™s Next Big Thing - Wearable Computing (Part 1)
    How To Basic Post A Video To Youtube
    Qooq - The First Culinary Tablet Made For The Kitchen
    Cutting Edge Technology (Part 4)
    Group Test - Mid-Range Maestros (Part 1) : Sony Xperia T
    Videography Canyons - Going It Alone
    Microsoft Enterprise Library : Banishing Validation Complication - Diving in With Some Simple Examples (part 1)
    Top 10
    Sharepoint 2013 : Building a BCS-enabled Business Solution : Building an Integrated BCS Solution with an App for SharePoint Containing an App for Office
    Business Connectivity Services in Apps for SharePoint 2013 : Building an App-level BCS Solution for Office 365 SharePoint Online
    Business Connectivity Services in SharePoint 2013 : Adding a Business Data Connectivity Model to Office 365 SharePoint Online
    Remote Event Receivers in Sharepoint 2013 : Introducing Remote Event Receivers
    Windows Server 2008 and Windows Vista : Common GPO Troubleshooting Tools (part 3) - GPResult, GPOTool
    Windows Server 2008 and Windows Vista : Common GPO Troubleshooting Tools (part 2) - GPMC
    Windows Server 2008 and Windows Vista : Common GPO Troubleshooting Tools (part 1) - GPLogView
    Windows Server 2008 and Windows Vista : Using Event Logging for Troubleshooting (part 4) - Summary of Group Policy Event IDs
    Windows Server 2008 and Windows Vista : Using Event Logging for Troubleshooting (part 3) - Divide the Custom View of the Log into Three Phases
    Windows Server 2008 and Windows Vista : Using Event Logging for Troubleshooting (part 2)