Friday, February 3, 2012

Visual Studio 2010: Configure the Parallel Execution of Unit Tests

Today almost every machine has multiple CPU’s or a CPU with multiple cores. Unfortunately Visual Studio 2010 is not using most of this power. However you can change the Visual Studio 2010 configuration to run Unit Tests  in parallel.
How To Enable Parallel Execution of Unit Tests
1. Create a new Test Project in Visual Studio 2010
2. Right click on “Local.testsettings” and click “Open With”, choose “Xml (Text) Editor” and hit OK.
3. Expand the Execution Tag and add an additional attribute called – parallelTestCount:
<TestSettings>
 <Description>These are default test settings for a local test run.</Description>
 <Deployment enabled="false" />
 <Execution parallelTestCount="3">
  ...
 </Execution>
</TestSettings>


You can specify the following numbers:
  • 0 = Auto configure: Visual Studio will try to optimize based on the CPU and core count.
  • Another number=Define the number of tests to run in parallel yourself.

No comments: