Вопрос

We're running our unit tests with mstest executed by our buildserver.

We have the convention that each unit test project ends with ".Test" and each integration test project ends with ".IntegrationTest"

Is it possible to specify for mstest to run all tests from the projects matching our conventions?

Right now, we manually list all our test projects like this in one single line, and it's getting really tedious and unmaintainable:

"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 /testcontainer:D:\workspace\unittestjob\solution\project8.Test\bin\Release\project8.Test.dll

Это было полезно?

Решение

It can be done with some PowerShell magic:

$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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top