Поделиться через


Editing a Test Run Configuration XML File

As described in How to: Edit a Test Run Configuration File, you can change a test run configuration in two ways: by using the test run configuration editor or by editing the XML of the test run configuration file. In general, first try to make changes by using the test run configuration editor. If the particular configuration setting that you want to change cannot be changed that way, edit the test run configuration file.

To help you determine which method to use, this topic shows the general structure of a test run configuration file and provides two examples of settings that you can edit manually but cannot edit by using the test run configuration editor.

When you change test run configuration settings by using the test run configuration editor, you see those changes reflected in this file. When you change values in this file, you see some, but not all, of the changes reflected in the test run configuration editor.

For more information about how to use the test run configuration editor, see How to: Specify a Test Run Configuration.

Sample Test Run Configuration File

In the following example file, certain elements are shown in bold text. These elements correspond to general areas of settings that you can make by using the test run configuration editor.

<?xml version="1.0" encoding="utf-8"?>

<Tests>  

    <TestRunConfiguration type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration">

      <id type="Microsoft.VisualStudio.TestTools.Common.TestRunConfigurationId">

        <id type="System.Guid">5d9344ed-bbde-4850-b05e-a7058096e956</id>

      </id>

    <name type="System.String">TestRunConfig1</name>

    <description type="System.String">This is a default test run configuration for a local test run.</description>

    < isCodeCoverageEnabled type="System.Boolean">True</isCodeCoverageEnabled>

    <codeCoverageItems type="System.Collections.Generic.List`1[[Microsoft.VisualStudio.TestTools.Common.CodeCoverageItem, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]">

    <_items type="Microsoft.VisualStudio.TestTools.Common.CodeCoverageItem[]">

      <element type="Microsoft.VisualStudio.TestTools.Common.CodeCoverageItem">

        <binaryFile type="System.String">bin\Debug\ClassLibrary1.dll</binaryFile>

        <keyFile type="System.String">Library1.snk</keyFile>

        <pdbFile type="System.String">bin\Debug\ClassLibrary1.pdb</pdbFile>

        <instrumentInPlace type="System.Boolean">True</instrumentInPlace>

        <outputDirectory type="System.String" />

      </element>

      </_items><_size type="System.Int32">1</_size>

      <_version type="System.Int32">1</_version>

    </codeCoverageItems>

    <codeCoverageKeyFile type="System.String" />

    <aspNetProjectCoverageItems type="System.Collections.Generic.List`1[

[Microsoft.VisualStudio.TestTools.Common.AspNetProjectItem, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0,

Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]">

    <_size type="System.Int32">0</_size>

    <_version type="System.Int32">0</_version>

    </aspNetProjectCoverageItems>

    < isExecutedRemotely type="System.Boolean">False</isExecutedRemotely>

    <bucketSize type="System.Int32">200</bucketSize>

    <bucketThreshold type="System.Int32">1000</bucketThreshold>

    < runTimeout type="System.Int32">0</runTimeout>

    <testTimeout type="System.Int32">300000</testTimeout>

    <agentNotRespondingTimeout type="System.Int32">300000</agentNotRespondingTimeout>

    <deploymentTimeout type="System.Int32">300000</deploymentTimeout>

    < controllerName type="System.String" />

    <plugins type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">

    <_size type="System.Int32">0</_size>

    <_version type="System.Int32">0</_version>

    </plugins>

    <testTypeSpecificData type="System.Collections.Generic.Dictionary`2[[Microsoft.VisualStudio.TestTools.Common.TestType, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.VisualStudio.TestTools.Common.ITestTypeSpecificRunConfigurationData, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]">

    <buckets type="System.Int32">-1,-1,0</buckets>

      <entries type="System.Collections.Generic.Dictionary`2+Entry[[Microsoft.VisualStudio.TestTools.Common.TestType, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.VisualStudio.TestTools.Common.ITestTypeSpecificRunConfigurationData, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]][]">

        <element type="Microsoft.VisualStudio.TestTools.WebTesting.WebTestRequestHeader, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

          <m_name type="System.String">User-Agent</m_name>

          <m_value type="System.String">Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)</m_value>

        </element>

      </entries>

    <count type="System.Int32">1</count>

    <version type="System.Int32">1</version>

    <freeList type="System.Int32">-1</freeList>

    <freeCount type="System.Int32">0</freeCount>

    <comparer type="System.Collections.Generic.ObjectEqualityComparer`1[[Microsoft.VisualStudio.TestTools.Common.TestType, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]" />

    </testTypeSpecificData>

    <userDeploymentRoot type="System.String" />

    <useDefaultDeploymentRoot type="System.Boolean">True</useDefaultDeploymentRoot>

    <deploymentItems type="Microsoft.VisualStudio.TestTools.Common.DeploymentItemCollection" />

    <testRunNamingScheme type="Microsoft.VisualStudio.TestTools.Common.TestRunNamingScheme">

      <appendTimeStamp type="System.Boolean">True</appendTimeStamp>

      <useDefault type="System.Boolean">True</useDefault>

    </testRunNamingScheme>

    < setupCommand type="System.String" />

    <cleanupCommand type="System.String" />

    <abortRunOnError type="System.Boolean">False</abortRunOnError>

    <mapIPAddresses type="System.Boolean">False</mapIPAddresses>

    <agentProperties type="System.Collections.Specialized.StringDictionary, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    < hostData type="Microsoft.VisualStudio.TestTools.Common.HostRunConfigurationData">

    <mapHostSpecificData type="System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],

[Microsoft.VisualStudio.TestTools.Common.IHostSpecificRunConfigurationData, Microsoft.VisualStudio.QualityTools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]">

    <count type="System.Int32">0</count>

    <version type="System.Int32">0</version>

    <freeList type="System.Int32">0</freeList>

    <freeCount type="System.Int32">0</freeCount>

    <comparer type="System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" />

    </mapHostSpecificData>

    </hostData>

    <ignoredDependentAssemblies type="System.String" />

    <apartmentState type="System.Threading.ApartmentState">

    <value__ type="System.Int32">0</value__>

    </apartmentState>

  </TestRunConfiguration>

</Tests>

Examples

The following sections show how to make specific changes in the XML file that controls test run configuration. You must make these changes in the XML because you cannot make them by using the test run configuration editor.

  • Changing the Default Location for Test Results

  • Changing Instrumentation Location and Specifying Additional Key Files

Changing the Default Location for Test Results

When you run tests, the results of those tests are automatically saved to disk in a default location. If you do not change the test run configuration XML file, the Boolean variable useDefaultDeploymentRoot retains its default value of True. In this case, test results are saved to the following locations:

  • The results of tests that you run in the Visual Studio IDE are saved to the TestResults folder under the current solution folder.

  • The results of tests that you run using the command-line command MSTest.exe are saved in the TestResults folder under the current folder. 

You can change this default location by changing two settings. First, set useDefaultDeploymentRoot to False. Then, specify a new value for the default folder.

For example, change this:

<useDefaultDeploymentRoot type="System.Boolean">True</useDefaultDeploymentRoot>

to this:

<useDefaultDeploymentRoot type="System.Boolean">False</useDefaultDeploymentRoot >

<userDeploymentRoot

  type="System.String">C:\My Documents\Visual Studio\Projects\MyResults</userDeploymentRoot>

  <runDeploymentRoot type="System.String" />

Changing Code-Coverage Instrumentation Location and Specifying Additional Key Files for Re-Signing

In the test run configuration editor, you can select artifacts to instrument to enable code coverage. Additionally, you can specify whether to instrument them in place, and you can specify a key file used to re-sign strong-named assemblies after they have been instrumented.

These settings apply to the entire test run, which means they are applied to all assemblies. If you want to use different settings with individual assemblies, you must do so in the test run configuration XML file.

In this example, you have two code coverage binaries: ClassLibrary1.dll and ClassLibrary2.dll. You can specify, for example, that ClassLibrary1.dll should be instrumented in-place, but not ClassLibrary2.dll. Also you can specify that ClassLibrary1.dll is to be re-signed after instrumentation with Library1.snk and ClassLibrary2.dll with a different key file, Library2.snk.

The following XML shows how to do this. The elements shown here, each of which represents an assembly, are child elements of the <codeCoverageItems> element.

  <element type="Microsoft.VisualStudio.TestTools.Common.CodeCoverageItem">

    <binaryFile type="System.String">bin\Debug\ClassLibrary1.dll</binaryFile>

    <keyFile type="System.String">Library1.snk</keyFile>

    <pdbFile type="System.String">bin\Debug\ClassLibrary1.pdb</pdbFile>

    <instrumentInPlace type="System.Boolean">True</instrumentInPlace>

    <outputDirectory type="System.String" />

  </element>

  <element type="Microsoft.VisualStudio.TestTools.Common.CodeCoverageItem">

    <binaryFile type="System.String">bin\Debug\ClassLibrary2.dll</binaryFile>

    <keyFile type="System.String">Library2.snk</keyFile>

    <pdbFile type="System.String">bin\Debug\ClassLibrary2.pdb</pdbFile>

    <instrumentInPlace type="System.Boolean">False</instrumentInPlace>

    <outputDirectory type="System.String" />

  </element>

See Also

Tasks

How to: Edit a Test Run Configuration File

Concepts

Instrumenting and Re-Signing Assemblies

Other Resources

Command-Line Test Execution