0

A newbie and first question on this forum. My first script successfully runs tests in parallel using mstest with PowerShell v4.0 workflow. But as "InlineScript" has the limitation of running 5 in parallel, trying to re-design the script to something without "InlineScript". While I could make the second script work for single test with hard coded test name, getting issues when I try to pull all the tests for run. Please take a look at both the scripts and suggest:

First Script:

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

Second Script:

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

1 Answer 1

0

Some more retry and I could make it work by using nested foreach. Thank you anyways.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.