Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing custom arguments as Command-line argument by running the MsTest.exe command prompt or via bat file

Tags:

mstest

My need is to Pass a custom arguments/Parameter to the unit test when running via the MsTest in the Command-line. The argument must be as command line argument and need to access the param value inside the test class or method.

like image 897
Hasan K Avatar asked Oct 13 '11 10:10

Hasan K


People also ask

How do I run MSTest from command line?

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.

How do you capture command line arguments?

To pass command line arguments, we typically define main() with two arguments : first argument is the number of command line arguments and second is list of command-line arguments. The value of argc should be non negative. argv(ARGument Vector) is array of character pointers listing all the arguments.


1 Answers

The MSTest command line does not support this option. Please look for a way to:

  1. create a text or configuration file
  2. start mstest
  3. read that file from within your test.

A similar suggestion is posted in MSTest Command Line Settings.

like image 153
kroonwijk Avatar answered Nov 10 '22 13:11

kroonwijk