单元测试 – TFS构建和测试影响

我正在玩TFS构建的Test Impact功能.

如果您使用.vsdmi文件似乎不能使用此功能,但仅当您使用.testsettings文件时(尽管VSDMI文件包含对测试设置文件的引用).

我已在测试设置文件中允许Test Impact,以及TFS构建配置等.
我需要使用VSDMi文件的原因是我创建了一个我希望在CI中执行的测试列表.问题是所有版本都显示“没有受影响的测试”,虽然我知道有一些.

我在这里错过了什么吗?请查找附带的vsdmi文件,testsettings文件和TFS构建配置的快照.

以下是.testsettings文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Master" id="68af9170-92f5-49d8-83dd-827359a79042" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <Deployment>
    <DeploymentItem filename="..\Common\Terra.Environment.Common.Data.Test\TpEnvFileParser\InputFiles\" />
    <DeploymentItem filename="..\Common\Terra.Environment.Fake\FakeData\HSW\Resources" />
    <DeploymentItem filename="..\Tpie.Engines.Build\Tpie.Engines.Build.Test\ExpectedFiles\" />
    <DeploymentItem filename="..\Tpie.Engines.Build\Tpie.Engines.Build.Test\Resources\" />
    <DeploymentItem filename="..\Common\Terra.Environment.Common.Model\bin\Debug\TerraEntitiesModel.ssdl" />
    <DeploymentItem filename="..\Common\Terra.Environment.Common.Model\bin\Debug\TerraEntitiesModel.csdl" />
    <DeploymentItem filename="..\Common\Terra.Environment.Common.Data.Test\PListFileParser\InputFiles\" />
    <DeploymentItem filename="..\Common\Terra.Environment.Common.Model\bin\Debug\TerraEntitiesModel.msl" />
    <DeploymentItem filename="..\Tpie.Client\Tpie.Client.Common.Test\ExcelParsers\InputFiles\" />
    <DeploymentItem filename="..\Tpie.Engines.Build\Tpie.Engines.Build.TestProgram\Templates\" />
  </Deployment>
  <Execution>
    <ExecutionThread apartmentState="MTA" />
    <Timeouts runTimeout="1800000" testTimeout="300000" />
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
      <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
        <Browser name="Internet Explorer 7.0">
          <Headers>
            <Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
            <Header name="Accept" value="*/*" />
            <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
            <Header name="Accept-Encoding" value="GZIP" />
          </Headers>
        </Browser>
      </WebTestRunConfiguration>
    </TestTypeSpecific>
    <AgentRule name="LocalMachineDefaultRole">
      <DataCollectors>
        <DataCollector uri="datacollector://Microsoft/TestImpact/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TraceCollector.TestImpactDataCollector, Microsoft.VisualStudio.TraceCollector, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        </DataCollector>
      </DataCollectors>
    </AgentRule>
  </Execution>
</TestSettings>

这是.vsmdi文件:

<?xml version="1.0" encoding="UTF-8"?>
<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <TestList name="TPIE Auto Build" id="2cbc1525-8079-4959-a126-4d4fb8fdb803" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
    <TestLinks>
      <TestLink id="ee8dae77-c23e-df6b-c6b5-4be930087750" name="LevelTestConditionGroupCheckCalculationDataTypeVoltageTest" storage="..\tpie.client\tpie.client.common.test\bin\debug\tpie.client.common.test.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <TestLink id="74441000-f8e5-ac1b-fbd6-bb94da0bf3ce" name="LevelPowerSequenceBlockCheckSequenceElementTest" storage="..\tpie.client\tpie.client.common.test\bin\debug\tpie.client.common.test.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <TestLink id="afb21bed-4eff-9f9f-7e58-c72e7d133b32" name="TestGetMiscEnvironmentVariables" storage="..\server\terra.binmatrix.server.test\bin\debug\terra.server.bl.test.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </TestLinks>
  </TestList>
  <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
    <RunConfiguration id="68af9170-92f5-49d8-83dd-827359a79042" name="Master" storage="master.testsettings" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </TestList>
</TestLists>

谢谢,
布丝

最佳答案 这有点棘手,但它确实有效.

如果要运行测试影响分析,则需要设置Disable Test = true和Analyze Test Impact = true.

我做了以下事情

>使用vsmdi创建CI构建类型
>设置构建以运行测试(禁用测试= false)
>选择vsmdi
>运行两个或三个构建来收集测试数据
>如上所述切换标志

点赞