How does Mstest work round the 260 max char limit

Were currently running teamcity on Windows Server 2012.

When  using the Mstest plugin, were able to supply a large amount of "individual" tests via the plug in dialog. This feature works fine.

But I want provide these tests automatically, so I want to supply these from a file and execute them via cmd or powershell (instead of using the mstest plugin).


e.g.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe /testcontainer:src\bin\Debug\The.Tests.Ui.dll /resultsfile:src\Results\testResults.trx /testsettings:src\config\remote.testsettings /test:CantMTAOrRevisedBinderWithDatafixInProgress /test:CantMTAifRevisedBinderInProgress      /test:CantRevisedBinderIfMTAInprogress /test:NTUtest     /test:RemoveLimitsAndDeductsValidationTests /test:WorksheetMandatoryTests     /test:PremiumAndFeesTestWithoutRater /test:RenewPolicy /test:RenewalOfRententionOfLinks     /test:ShouldBeAbleToDeleteImportedEmails /test:VerifyRiskManagerOnRisk     /test:ChangeEditMulipleDocuments /test:QuoteWhileDatesAreTBD /test:EndToEndSubToIssue"



But when I concatenate the cmd / powershell string and execute I get the max 260 length error .

How does the plugin no run into the same issues?

1 comment
Comment actions Permalink

I think i've found the workaround. By adding the the arguments to an array, and using the -arguments switch on the start process. I hope each argument will be execute/posted during each iteration, rather than a full string post (which breaks the 260 limit)

Powershell script

$reader = [System.IO.File]::OpenText("src/Testlist/testlist.txt")
$arguments = @()
$executablePath = "%system.MSTest.11.0%"
$arguments += "/testcontainer:src\bin\Debug\Tests.Ui.dll"
$arguments += "/resultsfile:src\Results\testResults.trx"
$arguments += "/testsettings:src\config\remote.testsettings"

try {
    for(;;) {
        $line = $reader.ReadLine()
        if ($line -eq $null) { break }    
        $arguments += "/test:$line"       
    }
}
finally {
    $reader.Close()
}

Start-Process $executablePath -argument $arguments

0

Please sign in to leave a comment.