DCSIMG
Run Unit Tests in Parallel using Visual Studio 2010 - Shai Raiten

Shai Raiten

 Subscribe

Run Unit Tests in Parallel using Visual Studio 2010

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

image

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.

image

image

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

image

 

This is my code for that Demo:

image

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 Smile

image

image

Enjoy

Comments

December 31, 2010 – TFS Links and Quick Hits | Learn TFS said:

Pingback from  December 31, 2010 – TFS Links and Quick Hits | Learn TFS

# December 31, 2010 3:06 PM

Twitter Trackbacks for Run Unit Tests in Parallel using Visual Studio 2010 - Shai Raiten [microsoft.co.il] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Run Unit Tests in Parallel using Visual Studio 2010 - Shai Raiten         [microsoft.co.il]        on Topsy.com

# December 31, 2010 9:54 PM

Jim Calhoun said:

Question 0

Does this work when using a controller agent, meaning can I run parallel on multiple agents?

Question 1

I read somewhere that when you have more than one agent, the first agent will take the first 100 tests, the second the next hundred, etc.  If I have have 90 very long running tests, can I split them among 3 agents?

Question 2.  If I want to run all 90 tests on each agent (XP, Vista, 7) is there a way to do that?

# January 4, 2011 1:59 AM

shair said:

Hi Jim,

This will not work when using Agents.

Both Question 1 and 2 are possible using Test Agenst and Load Test.

# January 4, 2011 6:53 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: