Monday, September 3, 2012

Running VSTS Webtests using MSTest.exe's /testcontainer option

I created a little window app that allows selecting one or more of our webtests and running the MSTest executable using .Net's ProcessStartInfo class in a separate thread created using the BackgroundWorker class.  I like using the BackgroundWorker class as it keeps multi-threading simple.

It took some trial and error plus some careful reading of MSDN's MSTest.exe Command-Line Options to figure out that I couldn't use the /testmetadata option. The reason was our team had created mulitple test lists with the same webtest appearing in several of the lists.  When I used this syntax:

     MSTest.exe /testmetada:mytests.vsmdi /test:webtest1.webtest

my tests got executed one time per test list!

That took some head scratching to figure out the workaround:  use the /testcontainer: option.  This syntax worked:

        MSTest.exe /testsettings:mysettings.testsettings /testcontainer:webtest1 /testcontainer:webtest2 /testcontainer:webtest3

I've used this syntax successfully even when starting 30 or more webtests in one command.

No comments:

Post a Comment