在MSBuild中指定MSTest参数 [英] Specify MSTest parameters in MSBuild

查看:90
本文介绍了在MSBuild中指定MSTest参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to prevent certain (MSTest) unit tests from being run on our build server. I'd really like to just add a TestCategory, and then specify:

/category:"!RequiresLoginCredentials"

但是我不确定如何在msbuild项目文件中指出这一点.

But I'm not sure how to indicate that in the msbuild project file.

构建文件的相关部分当前具有:

The relevant section of the build file currently has:

  <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知之甚少.

I'm guessing this is a simple addition, but I know very little about msbuild.

谢谢!

推荐答案

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

I did a quick search for the answer and I think there are two possible solutions:

  1. 根据您的描述,您似乎正在尝试使用

  1. From what you described, looks like you're trying to run the tests using the TestToolTask task of MSBuild. Unfortunately, I don't think you can pass MSTest arguments directly to this task. To accomplish what you want, you need to specify the tests you want to run in a test list, and pass the test list to this task. You need to use the MetadataFile property as shown in the example in your post.

您可以直接使用MSBuild的 Exec任务调用MSTest.exe.这样,您就可以自由传递所需的参数.

You can invoke MSTest.exe directly using the Exec task of MSBuild. This way you have the freedom to pass in the arguments you want.

这篇关于在MSBuild中指定MSTest参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆