在MSBuild中指定MSTest参数

在MSBuild中指定MSTest参数,msbuild,mstest,Msbuild,Mstest,我试图阻止某些(MSTest)单元测试在构建服务器上运行。我只想添加一个TestCategory,然后指定: /category:"!RequiresLoginCredentials" 但我不确定如何在msbuild项目文件中指出这一点 生成文件的相关部分当前有: <ItemGroup> <!-- TEST ARGUMENTS If the RunTest property is set to true then the following test

我试图阻止某些(MSTest)单元测试在构建服务器上运行。我只想添加一个TestCategory,然后指定:

/category:"!RequiresLoginCredentials"
但我不确定如何在msbuild项目文件中指出这一点

生成文件的相关部分当前有:

  <ItemGroup>
    <!--  TEST ARGUMENTS
     If the RunTest property is set to true then the following test arguments will be used to run 
     tests. Tests can be run by specifying one or more test lists and/or one or more test containers.

     To run tests using test lists, add MetaDataFile items and associated TestLists here.  Paths can 
     be server paths or local paths, but server paths relative to the location of this file are highly 
     recommended:

        <MetaDataFile Include="$(BuildProjectFolderPath)/HelloWorld/HelloWorld.vsmdi">
            <TestList>BVT1;BVT2</TestList>
        </MetaDataFile>

     To run tests using test containers, add TestContainer items here:

        <TestContainer Include="$(OutDir)\HelloWorldTests.dll" />
        <TestContainer Include="$(SolutionRoot)\TestProject\WebTest1.webtest" />
        <TestContainer Include="$(SolutionRoot)\TestProject\LoadTest1.loadtest" />

     Use %2a instead of * and %3f instead of ? to prevent expansion before test assemblies are built
    -->
    <TestContainer Include="$(OutDir)\UnitTests.dll" />

  </ItemGroup>

我猜这是一个简单的加法,但我对msbuild知之甚少


谢谢

我快速搜索了答案,我认为有两种可能的解决方案:

  • 从您描述的内容来看,您似乎正在尝试使用MSBuild的函数运行测试。不幸的是,我认为您不能将MSTest参数直接传递给此任务。要完成所需的任务,需要在测试列表中指定要运行的测试,并将测试列表传递给此任务。您需要使用MetadataFile属性,如本文中的示例所示

  • 可以使用MSBuild的函数直接调用MSTest.exe。这样你就可以自由地传递你想要的论点


  • 我快速搜索了答案,我认为有两种可能的解决方案:

  • 从您描述的内容来看,您似乎正在尝试使用MSBuild的函数运行测试。不幸的是,我认为您不能将MSTest参数直接传递给此任务。要完成所需的任务,需要在测试列表中指定要运行的测试,并将测试列表传递给此任务。您需要使用MetadataFile属性,如本文中的示例所示

  • 可以使用MSBuild的函数直接调用MSTest.exe。这样你就可以自由地传递你想要的论点


  • 您使用的构建服务器版本是什么?我相信我们使用的是MSBuild 4,使用的是TFS 2008。我还没有使用TFS,但这类事情通常不是用TestManager配置的吗?TestManager是TFS 2010中的一个功能:)在2010年,您可以通过build definition.Lolz来完成。然后我投票给exec任务。您使用的构建服务器的版本是什么?我相信我们使用的是MSBuild 4,使用的是TFS 2008。我没有使用TFS,但这类事情不是通常用TestManager配置的吗?TestManager是TFS 2010中的一个功能:)在2010年,您可以通过build definition.Lolz来完成。那么,我投票赞成执行任务。