Passing user arguments as a command line argument by running the command line MsTest.exe or bat file

I need to pass the user arguments / unit test parameter when running through MsTest at the command line . The argument must be a command line argument and must access the parameter value inside the test class or method.

+4
source share
2 answers

The MSTest command line does not support this option. Please find a way:

  • create text or configuration file
  • start mstest
  • read this file from your test.

A similar proposal is published in the MSTest command-line options .

+1
source

In your comment on kroonwijk, you said that you are trying to specify a specific configuration file for use in a test run. The way I've done in the past is to create some App.config transformations (for example, App.Test.config), where the "Test" part matches the configuration name that I set in the configuration manager. Then, when I build with this particular configuration, the appropriate transformations are applied, and the resulting configuration file has the values ​​that I need for this environment.

+1
source

All Articles