wildcard test containers to mstest. exe

十年热恋 提交于 2019-12-04 01:03:51
oɔɯǝɹ

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:&quot;%(RecursiveDir)%(Filename)%(Extension)&quot;', ' ')"
          />
</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).

It is also possible to use cmd file to collect containers by wildcard into a single variable, and then run mstest with this variable expanded:

call "%VS100COMNTOOLS%vsvars32"
@setlocal enabledelayedexpansion enableextensions
@set list=
@for %%x in (.\Bin\Debug\*Test.dll) do set list=!list! /testcontainer:%%x
@set list=%list:~1%

mstest %list%
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!