Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using .runsettings via commandline in MSTest.exe

I've looked through the documentation for MSTest but still struggling to understand the proper use of testsettings/runsettings in the test project. This article indicates that .runsettings should be all that is required and there is no longer a need for a .testsettings file (VS2010 and up).

I have created a series of tests, which use Selenium Driver to perform integration tests for our application. Since these are integration tests I need a way to supply a different parameters depending on the environment these tests are executed against. To achieve this, I created two separate .runsettings files: one for local development environment and one for staging.

Running those tests through Visual Studio works just fine. Visual Studio gives you an option to specify the settings file, through the Test/Test Settings/Select Test Settings menu option.

On my build server, however, I must rely on the command line tools and MSTest.exe in particular. The following command line executes the tests and builds the results file correctly.

MSTest.exe /noisolation /resultsfile:"D:\Results\TestResult.trx" /testcontainer:"d:\Project\bin\Release\Project.Tests.dll" 

However, all the tests are failing due to the NullReferenceException thrown when we attempt to retrieve Parameters that I specified in the .testsettings.

Is there a way to pass a path to the appropriate .testsettings file via MSTest.exe arguments? I reviewed the docs and /help options and the closest option that I found was /testsettings, which isn't what I want since it's used to specify the path to the .testsettings file.

like image 971
DaRussian Avatar asked Nov 30 '15 18:11

DaRussian


People also ask

How do I run MSTest from command line?

MSTest utility. To access the MSTest tool, add the Visual Studio install directory to the path or open the Visual Studio Group from the Start menu, and then open the Tools section to access the Visual Studio command prompt. Use the command MSTest from the command prompt.

Where do I put .runsettings file?

Manually select the run settings fileIn the IDE, select Test > Configure Run Settings > Select Solution Wide runsettings File, and then select the . runsettings file.

Does Visual Studio use MSTest or VSTest?

The Visual Studio Tests build runner integrates functionality of the MSTest framework and VSTest console runner. Support for both frameworks enables TeamCity to execute tests and automatically import their test results.


1 Answers

When using a .runsettings file, you need to use vstest.console.exe, not mstest.exe. If you use mstest.exe you still need to use a .testsettings file similar to the ones you used with Visual Studio 2010.

like image 165
jessehouwing Avatar answered Oct 13 '22 00:10

jessehouwing