这个论坛上的新手和第一个问题。我的第一个脚本使用带有 PowerShell v4.0 工作流的 mstest 成功地并行运行测试。但是由于“InlineScript”具有并行运行 5 个的限制,因此尝试将脚本重新设计为没有“InlineScript”的东西。虽然我可以使第二个脚本适用于具有硬编码测试名称的单个测试,但当我尝试拉出所有测试以运行时遇到问题。请看一下这两个脚本并提出建议:
第一个脚本:
workflow Primary_Tests
{
$Workspace = "E:\Vishal_PS_Workspace"
$mstest = "C:\VisualStudio12\Common7\IDE\MSTest.exe"
$testlocation = "$Workspace\TEST\TestBin"
$RunName = Get-Date -format "yyyy-MM-dd-T-HH\hmm"
mkdir "$Workspace\TestResults\Results-$RunName"
$resultsDir = "$Workspace\TestResults\Results-$RunName"
$results = "/resultsfile:$resultsDir\$RunName.trx"
InlineScript { cd $Using:testlocation }
$tests = @("Test_01", "Test_006", "Test 013", "ST-002-002", "ST-001-002", "ST-032-002", "ST-012-002", "Test 016", "Test 143")
ForEach -Parallel -ThrottleLimit 10 ($test in $tests)
{
InlineScript { & $Using:mstest /TestContainer:"$Using:testlocation\$Using:test.webtest" /resultsfile:"$Using:resultsDir\$Using:test.trx" }
}
}
Primary_Tests
第二个脚本:
Workflow Parallel_Tests
{
$Workspace = "E:\Vishal_PS_Workspace"
$mstest = "C:\VisualStudio12\Common7\IDE\MSTest.exe"
$testlocation = "$Workspace\TEST\TestBin"
$RunName = Get-Date -format "yyyy-MM-dd-T-HH\hmm"
mkdir "$Workspace\TestResults\Results-$RunName"
$resultsDir = "$Workspace\TestResults\Results-$RunName"
$results = "/resultsfile:$resultsDir\$RunName.trx"
$arguments = " /testcontainer:" + "$testlocation\" + "Test_01.webtest"
$tests = @("Test_01")
ForEach -Parallel -ThrottleLimit 10 ($test in $tests)
{
Invoke-Expression "$mstest $arguments $results"
}
}
Parallel_Tests