Using .runsettings via the command line in MSTest.exe

I looked at the documentation for MSTest , but still try my best to understand the correct use of tests / settings in a test project. This article states that .runsettings should be all that is required, and there is no longer a need for a .testsettings file (VS2010 and above).

I created a series of tests that use the Selenium Driver to perform integration tests for our application. Since these are integration tests, I need a way to supply various parameters depending on the environment with which these tests are performed. To do this, I created two separate .runsettings files: one for the local development environment and one for hosting.

Running these tests using Visual Studio works fine. Visual Studio gives you the opportunity to specify the settings file using the menu item Test / Testing / Select test parameters .

However, on my build server, I should in particular use the command line tools and MSTest.exe . The following command line runs the tests and builds the result file correctly.

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

However, all tests fail because of a NullReferenceException when we try to get the parameters that I specified in .testsettings.

Is there a way to pass the path to the corresponding .testsettings file through the MSTest.exe arguments? I looked at the document options and //, and the closest option I found was / testsettings, which I don't want, since it used the path to the .testsettings file.

+7
visual-studio visual-studio-2010 selenium jenkins mstest
source share
1 answer

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

+10
source share

All Articles