Running unit tests in parallel
-
Thursday, January 14, 2010 8:49 PMHello,
I've been trying to get our unit tests to run on both cores. All google searches seem to lead me back to this link:
http://blogs.msdn.com/vstsqualitytools/archive/2009/12/01/executing-unit-tests-in-parallel-on-a-multi-cpu-core-machine.aspx
So far, it doesn't seem to actually work. I've tried this one two different machines, both of which have dual core processors, and I can't reproduce the claims in the article.
My steps to reproduce are:
1. Create a new Visual Studio 2010 project. From the Installed Templates, choose "Test Project".
2. Edit the "Local.testsettings", changing <Execution> to <Execution parallelTestCount="2">
3. Create 4 unit tests that all sleep for a few seconds.
4. Open the Test View, select all of the tests, then run selected.
Each test will run only after the previous finishes. I never see a case where two are "In Progress" at the same time.
Is there something really obvious I'm missing here? I've tried setting the "parallelTestCount" to 0, or 2, but it has no effect. When I set my "Select Active Test Settings", it's set to the correct file. Any thoughts?
Thanks.
All Replies
-
Thursday, January 14, 2010 10:50 PMModerator
It works for me in Beta 2. I defined 4 tests, put a 5 second sleep in each. When the tests begin to run I see 2 tests In Progress and 2 Pending. After 5 seconds the 2 tests move to Passed and the other 2 move to In Progress. 5 seconds after that the tests finish.
Michael Taylor - 1/14/10
http://p3net.mvps.org- Marked As Answer by Harry ZhuModerator Friday, January 22, 2010 9:20 AM
-
Tuesday, February 16, 2010 11:44 PMI have the RC installed and I'm having the same problem as Dan.
B.Young -
Wednesday, February 17, 2010 2:59 PMModerator
It is working in RC. You are not meeting one of the requirements. Here is the checklist:
- Running a multi-processor machine.
- Can only have unit tests running.
- Data adapters must be disabled.
- Correctly modified the settings file to enable parallel execution using the parallelTestCount attribute.
- Running only local tests.
Note that if you just create a new unit test project, write a couple of tests and then use F5 to run it then you won't get the parallel behavior. You also might not see it if the tests execute too quickly.
There is no UI to set up the parallel tests. If you make any changes to your test settings in the UI you'll lose the parallel settings. Additionally (whether a bug or by design) the parallel test option is only read when the project is loaded. Therefore if you change the setting you'll have to close the project and reopen it before it'll take effect. I'm not sure if you can switch to another test setting and then back or not. But that might work as well.
Michael Taylor - 2/17/2010
http://msmvps.com/blogs/p3net -
Wednesday, February 17, 2010 3:10 PMHung up on step 6 - Reloading the project worked.Thanks
B.Young

