Run Unit Tests in Parallel using Visual Studio 2010
Today almost each and every machine have multiple CPU’s or a CPU with multiple cores, so why not using them in order to speed up your tests runs and run more Tests in parallel.
In Visual Studio 2010 Microsoft added the ability to run Tests (Only for Unit Tests) in parallel.
- Data Collectors cannot be enabled if using Parallel execution.
- You must have multi-core/CPU machine
How To Enable Parallel Execution of Unit Tests
1. Create 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 additional attribute called – parallelTestCount:
What’s are your options:
- 0 = Auto configure: We will use as many tests as we can based on your CPU and core count
- Define the number of tests to run in parallel – If you don’t want to use all cores/cpu’s
This is my code for that Demo:
As you can see from the picture below I have 4 unit tests running in parallel and another picture below you can see my computer finally working