Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I force MSTest to use a new process for each test run?

We're using the VS 2010 test runner (MSTest) for automated functional testing. When we run tests from Visual Studio, VS creates a process called QTAgent32.exe, and it runs the tests in that process.

We've found that when we do multiple test runs, MSTest will reuse the same QTAgent32 process - the process ID does not change. This is a problem for us, since the code we're testing is P/Invoking to an unmanaged DLL. The DLL needs to be initialized only once during the lifetime of the process. We have an [AssemblyInitialize] method, but that executes once per test run. If we perform multiple test runs, it will execute more than once in the same process.

Every time we do a test run, MSTest creates a new appdomain; but these appdomains are all in the same process.

So I'm wondering: is there a way to tell the Visual Studio test runner to use a new process every time we run tests? I looked at the ".testsettings" configuration but didn't see anything relevant.

like image 991
Richard Beier Avatar asked Nov 18 '11 21:11

Richard Beier


People also ask

Does MSTest run tests in parallel?

The biggest advantage of MSTest is that it allows parallelization at the method level. As opposed to the other frameworks which only allow parallelization at the class level. So, for example, If you have 100 test methods in 5 classes, MSTest will let you run 100 tests in parallel.

Is MSTest a testing framework?

MSTest is a number-one open-source test framework that is shipped along with the Visual Studio IDE. It is also referred to as the Unit Testing Framework. However, MSTest is the same within the developer community. MSTest is used to run tests.

Which attribute should be used to mark a method as test method in MSTest testing?

The TestClass attribute denotes a class that contains unit tests. The TestMethod attribute indicates a method is a test method.

How do I run a specific test in Visual Studio?

Tests can be run from Test Explorer by right-clicking in the code editor on a test and selecting Run test or by using the default Test Explorer shortcuts in Visual Studio.


1 Answers

dont know how far you want to go with it, but one solution could be to create your unit test host

http://technet.microsoft.com/fr-fr/query/bb166558

this link shows how to create adapters, also you could then launch a new process for evertest, create a piped communication and tear it down after the test.

I know MS itself uses a different host for running tests under moles

http://research.microsoft.com/en-us/projects/pex/molestutorial.pdf

like image 184
np-hard Avatar answered Sep 21 '22 19:09

np-hard