MSTest command line options

We need to be able to pass the server address to the MSTest command line for our test suite, which is called by TeamCity Continuous Integration (CI) software.

Earlier, we created #if constants in C # unit tests that made changes to MSBuild.

Is there a better way? This path seems pretty hacked.

Is there a way to create configuration files and pass arguments to be used in MSTest?

+2
source share
1 answer

I am using the app.config file in my test project to configure my tests. The control contains the app.config file used by TeamCity to run tests.

When compiled, app.config is copied to the bin folder and renamed to [assembly_name] .config. You can then access any settings in the .config file from the test code using the ConfigurationManager .

On development systems, the .config file is configured to run tests against what has ever been used by the local test server that the developer uses.

I consider this the cleanest approach because it logs how the tests are configured in source control.

If you need more flexibility, you can configure an additional build step in TeamCity to modify the .config file as needed, using some XML conversions or string replacements from a custom MSBuild script.

+4
source

All Articles