通配符测试容器到 mstest.可执行程序 [英] wildcard test containers to mstest. exe
问题描述
是否可以将通配符 testcontainer 值传递给命令行 mstest.exe 而不是手动硬编码多个 testcontainer 值?比如
Mstest.exe/testcontainer:tests.dll
我想在我们的 tfs 2012 升级 template.xaml 构建过程中手动调用 mstest,使其行为类似于在默认 template.xaml 中运行测试的自动发现方式
如果不能,是否可以将其写入 bat 脚本以从给定的起始文件夹循环遍历文件夹?
MSTest
不采用 testcontainer 的通配符参数 (查看此处以获取有关命令行选项的参考).然而,它可以采用多个/testcontainer 参数,如下所示:
mstest.exe/testcontainer:a.test.dll/testcontainer:b.tests.dll
您必须以另一种方式提供这些参数.这可以使用批处理文件来完成,但 MSBuild
可能是更好的选择:
<项目组><TestAssemblies Include="***Tests.dll"/></项目组><目标名称="RunMSTest"><Exec Condition="'@(TestAssemblies)' != ''"Command="Mstest.exe @(TestAssemblies ->'/testcontainer:"%(RecursiveDir)%(Filename)%(Extension)"', ' ')"/></目标></项目>
(感谢 https://stackoverflow.com/a/2770682/62662 的转换)>
将 i 保存到一个文件 (testall.proj
),然后使用 MSBuild testall.proj
运行它,或者创建一个批处理文件来为您运行它.>
另请注意,mstest 在一个应用程序域中加载所有提供的测试容器,因此它们需要支持相同的平台目标(任何 cpu、x86、x64).
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:tests.dll
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
If not could this be written into a bat script to loop through folders from a given start folder?
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
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>
(with thanks to https://stackoverflow.com/a/2770682/62662 for the transform)
Save i to a file (testall.proj
), and run it with MSBuild testall.proj
, or create a batch file to run it for you.
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.可执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!