views:

695

answers:

1

I have 2 projects each one with its own unit test project, and one app.config for each project+test project pair. The tests do not fail if I run only one each time. But if use "Run all tests in solution" all tests will use just one of the app.config's, and it will be the wrong one for all tests in one of these test projects.

How do I run all tests from a single project without having to use separated solutions, so they don't use another project's app.config?

+2  A: 

I don't think you'll be able to. The problem you likely have is that Visual Studio is just going to pass a single test list to MSTest. MSTest on starting will use the config file of the first .DLL it comes across.

For performance reasons, MSTest won't tear down/spin up a new process when it encounters a test in a different .DLL and so it will never load the second config file.

As I see it you have two options.

  1. Merge the config files so that they can be shared across the tests.

  2. Change your tests so that they don't need config files. The fact that you have them would suggest that you are doing integration tests instead of unit tests that are isolated form their dependencies, though if you have a complex code base I can understand why it happens.

Richard Banks