Executing Unittests in parallel

My machine has a multi core processor, but my unittests only run one at a time.
screenshot of one unittest executed at a time

In Visual Studio 2010 the option to use more than one core and run unittests in parallel is there, but well hidden in the testsettings. You can change the default behavior (no parallel execution = 1) to automatic (0) or the number of cores you want to use. Open the local.testsettings file from the solution explorer with the XML editor. Locate the Execution tag and add the attribute parallelTestCount=0 to enable automatic parallel execution when available.
screenshot of testsettings in XML editor showing parallelTestCount attribute in Execution tag

After setting the parallelTestCount to automatic my unittests run in parallel on my dual-core machine. You might want to restart Visual Studio or do a clean build.
screenshot of two unittest executed in parallel
The execution time of the 17 unittests in my solution was sliced in half this way: 2 seconds to 1 second.

Read some of the details what is and isn’t possible on the MSDN blog post about executing unit tests in parallel: http://blogs.msdn.com/b/vstsqualitytools/archive/2009/12/01/executing-unit-tests-in-parallel-on-a-multi-cpu-core-machine.aspx

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Test and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.