【问题标题】:Run all unit tests with mstest in projects matching a name pattern在匹配名称模式的项目中使用 mstest 运行所有单元测试
【发布时间】:2014-03-26 10:18:02
【问题描述】:

我们正在使用我们的构建服务器执行的 mstest 运行我们的单元测试。

我们的约定是每个单元测试项目都以“.Test”结尾,每个集成测试项目都以“.IntegrationTest”结尾

是否可以指定 mstest 运行符合我们约定的项目中的所有测试?

现在,我们在一行中手动列出所有类似这样的测试项目,这变得非常乏味且无法维护:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest" /testcontainer:D:\workspace\unittestjob\solution\project1.Test\bin\Release\project1.Test.dll / testcontainer:D:\workspace\unittestjob\solution\project2.Test\bin\Release\project2.Test.dll /testcontainer:D:\workspace\unittestjob\solution\project3.Test\bin\Release\project3.Test.dll / testcontainer:D:\workspace\unittestjob\solution\project4.Test\bin\Release\project4.Test.dll /testcontainer:D:\workspace\unittestjob\solution\project5.Test\bin\Release\project5.Test.dll / testcontainer:D:\workspace\unittestjob\solution\project6.Test\bin\Release\project6.Test.dll /testcontainer:D:\workspace\unittestjob\solution\project7.Test\bin\Release\project7.Test.dll /测试容器:D:\workspace\unittestjob\solution\project8.Test\bin\Release\project8.Test.dll

【问题讨论】:

    标签: c# visual-studio visual-studio-2012 mstest


    【解决方案1】:

    这可以通过一些 PowerShell 魔法来完成:

    $temp = '/testsettings:D:\workspace\unittestjob\solution\local.testsettings /resultsfile:TestResult.trx ' ; #General stuff
    
    Get-ChildItem D:\workspace\unittestjob\solution\ -Filter *.Test.dll -Recurse | ? {$_.fullname -notmatch 'obj'} | % { $temp =  $temp + "/testcontainer:" + $_.FullName+ " "};  #Get all dlls, but exclude the ones from 'obj'. Add /testcontainer to each
    
    $temp  =  '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest" ' + $temp ; #Prepare the command of MSTest to be ran
    
    iex "& $temp"; #Run MSTest
    

    【讨论】:

      猜你喜欢
      • 2013-09-14
      • 2010-12-13
      • 1970-01-01
      • 2010-09-26
      • 2020-05-27
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      • 2011-04-24
      相关资源
      最近更新 更多