Visual Studio Team System
TestToolsTask Task

The TestToolsTask task runs the test for an end-to-end build or for a desktop build. Set a desktop build type by setting the property IsDesktopBuild to true.

TestToolsTask task is defined in Microsoft.TeamFoundation.Build.targets file as a part of the RunTestWithConfiguration target. It is stored in the <root>:\Program Files\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild folder on the Team Foundation Build server.

Parameters

Property Description

Condition

Optional String parameter.

Boolean expression that the MSBuild engine uses to determine whether this task will be executed. For information, see MSBuild Conditions.

BuildFlavor

Specifies the build configuration. For example, Debug.

Defined for end-to-end build only.

Platform

Specifies the platform. For example, x86 or Any CPU.

Defined for end-to-end (not desktop) build only.

PublishServer

Specifies the Team Foundation Server URL.

Defined for end-to-end build only.

PublishBuild

Specifies the build number for the build.

Defined for end-to-end build only.

SearchPathRoot

Specifies the search path for test files.

Defined for end-to-end and desktop builds.

PathToResultsFilesRoot

Specifies where test results get uploaded.

Defined for end-to-end and desktop builds.

MetaDataFile

Specifies the test metadata file. This file contains test lists and links to tests. For more information about test lists, see Using Test Lists. Test metadata files have the extension .vsmdi.

Defined for end-to-end and desktop builds.

RunConfigFile

Specifies the test configuration file. These files configure the way tests are run. For more information, see Configuring Test Execution. Test run configuration files have the extension .testrunconfig.

Defined for end-to-end and desktop builds.

TestLists

Specifies the test list that is contained in the test metadata file.

Defined for end-to-end and desktop builds.

TeamProject

Specifies the team project name. The team project name is generally defined by the New Team Build Type Creation Wizard. You can also specify a different name in the TfsBuild.proj file by modifying the TeamProject property.

Defined for end-to-end build only.

Remarks

The Microsoft.TeamFoundation.Build.targets file contains an instance of the TestToolsTask task that Team Foundation Build uses as a default implementation for the RunTestWithConfiguration target.

Microsoft.TeamFoundation.Build.targets file is stored in the <root>:\Program Files\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild folder on the Team Foundation Build server.

Example

The following XML describes the instance of TestToolsTask in the Microsoft.TeamFoundation.Build.targets file that is used for an end-to-end build.

<TestToolsTask
          Condition=" '$(IsDesktopBuild)'!='true' and '%(MetaDataFile.Identity)'!=''"
          BuildFlavor="$(Flavor)"
          Platform="$(Platform)"
          PublishServer="$(TeamFoundationServerUrl)"
          PublishBuild="$(BuildNumber)"
          SearchPathRoot="$(SearchPathRoot)"
          PathToResultsFilesRoot="$(TestResultsRoot)"
          MetaDataFile="%(MetaDataFile.Identity)"
          RunConfigFile="$(RunConfigFile)"
          TestLists="%(MetaDataFile.TestList)"
          TeamProject="$(TeamProject)"
          ContinueOnError="true" />

The following XML describes the instance of TestToolsTask in the Microsoft.TeamFoundation.Build.targets file that is used for a desktop build.

<TestToolsTask
          Condition=" '$(IsDesktopBuild)'!='false' and '%(MetaDataFile.Identity)'!=''"
          SearchPathRoot="$(SearchPathRoot)"
          PathToResultsFilesRoot="$(TestResultsRoot)"
          MetaDataFile="%(MetaDataFile.Identity)"
          RunConfigFile="$(RunConfigFile)"
          TestLists="%(MetaDataFile.TestList)"
          ContinueOnError="true" />
See Also

Tasks

How to: Configure and Run Build Verification Tests (BVTs)
How to: Customize Build Numbers
How to: Configure Tests with Build Types

Concepts

Team Foundation Build Tasks

Other Resources

Customizing Team Foundation Build
Team Foundation Build Targets, Tasks, and Properties

Tags :


Community Content

zotw
How to execute ALL tests for a solution on TFS server build
If you've got here because you wish to add Unit Test execution to your existing TFS server build to executeALL TESTS in your solution ("Why on earth would you want to do that?" you ask), and you've scoured the internet and become incredibly frustrated that all you can find are people who tell you how "easy" it is to do in TFS without actually telling you how to do it, this may help...

The long winded "help yourself" solution
Create a new build type (Team Explorer > ProjectName > Builds > (right click) > "New Build Definition" in VSTS 2008) as described above, and look for the secret hidden test options (hint: In the project File tab, Click the Create... button, select your project(s), then go to the Options tab. Aha! Test options! obvious!). Set them up to use your vsmdi (or better, *Test*.dll so that the tests will just automatically pick up any new dlls you write with the word "Test" in their name) and then look at the Test section of the TFSBuild.proj that it generates to find the magic line or two of XML that you need to add to your existing build script. Add it in and then you can just delete the new Build Type.

The short "here's the magic secret handshake" solution
You will no doubt be amazed to hear that the solution can be as simple as this:
  • In your main propertyGroup, make sure that you have set:
    <RunTest>true</Runtest>

  • In the first test <ItemGroup> where there are examples of how to add specific tests using <TestContainer> commands, add the following command:
    <TestContainer Include="$(OutDir)\%2aTest%2a.dll" />
(The %2a represents a wildcard asterisk, i.e. "$(OutDir)\*Test*.dll" but it is encoded in this way to stop it being expanded to early in the build process).

This will set up your build to run unit tests from all the dlls in your build that include Test in their filename.

HTH

Page view tracker