Question

In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument.

How do you get the arguments from MSTest?

Was it helpful?

Solution

VS 2008 test are compiled into DLLs which can't directly receive command line arguments as far as I know.

You could add a configuration file 'app.config' for the dll and use that instead.

Just beware, mstest only copies .config files for the test container being run at the time.

if you have the following...

mytest.dll
mytest.dll.config
lib.dll
lib.dll.config

and you reference lib.dll from mytest.dll, when you run the tests lib.dll.config will not get copied and your test may fail because of this.

OTHER TIPS

Perhaps you can use GetCommandLine().

Edit: GetCommandLine() is a win32-function, but there ought to be a corresponding .Net function for it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top