问题描述
是否可以将通配符testcontainer值传递给命令行mstest.exe,而不是手动对多个testcontainer值进行硬编码?如
Is it possible to pass wildcard testcontainer values to the command-line mstest.exe rather than manually hardcoding multiple testcontainer values? Such as
Mstest.exe/testcontainer:测试 .dll
Mstest.exe /testcontainer:tests.dll
我想在我们的tfs 2012升级template.xaml构建过程中手动调用mstest,以便它的行为类似于自动发现方式,类似于在默认template.xaml中运行测试
I'm wanting to manually invoke mstest in our tfs 2012 upgrade template.xaml build processso tthat it behaves like a autodiscovery way similar to running tests in default template.xaml
是否不能将其写入bat脚本以循环访问给定起始文件夹中的文件夹?
If not could this be written into a bat script to loop through folders from a given start folder?
推荐答案
MSTest
不使用testcontainer的通配符参数(在此处查找有关命令行选项的参考信息).但是,它可以采用多个/testcontainer参数,如下所示:
MSTest
doesn't take a wildcard parameter for the testcontainer (look here for a reference on the command line options). It can however take multiple /testcontainer arguments, as follows:
mstest.exe /testcontainer:a.test.dll /testcontainer:b.tests.dll
您将不得不以其他方式提供这些参数.可以使用批处理文件来完成此操作,但是MSBuild
可能是一个更好的选择:
You will have to supply these parameter another way. This can be done using a batch file, but MSBuild
may be a better choice for this:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="RunMSTest">
<ItemGroup>
<TestAssemblies Include="**\*Tests.dll"/>
</ItemGroup>
<Target Name="RunMSTest">
<Exec Condition=" '@(TestAssemblies)' != ''"
Command="Mstest.exe @(TestAssemblies ->'/testcontainer:"%(RecursiveDir)%(Filename)%(Extension)"', ' ')"
/>
</Target>
</Project>
(感谢 https://stackoverflow.com/a/2770682/62662 进行的转换)
将i保存到文件(testall.proj
)中,然后使用MSBuild testall.proj
运行它,或创建一个批处理文件来为您运行它.
Save i to a file (testall.proj
), and run it with MSBuild testall.proj
, or create a batch file to run it for you.
还要注意,mstest在一个应用程序域中加载所有提供的testcontainer,因此它们将需要支持相同的平台目标(任何cpu,x86,x64).
Also note that mstest loads all supplied testcontainers in one application domain, so they will need to support the same platform target (any cpu, x86, x64).
这篇关于通配符测试容器以进行mstest.可执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!