Enable parallel execution of tests using the Visual Studio Test Runner 2015.1

2015-11-16

Does your machine have multiple CPU's or cores? Are your tests truly independent and thread safe? In that case you'll be able to speed up your test runs considerably by enabling multi-threaded support to the Visual Studio Test Runner.

This works in both Visual Studio as on your build server.

To get the benefits, add the following snippet to your .runsettings file:


<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <RunConfiguration>
    <!-- Add this line, default is 1, which makes it run single threaded -->
    <!-- 0 will use all available cores -->
<MaxCpuCount>8</MaxCpuCount>
  </RunConfiguration>
</RunSettings>


This is an all or nothing setting in Visual Studio, but in TFS Build you can specify multiple test runs, each with their own .runsettings. So for your CI build you'll be able to run all your unit tests in parallel, but then execute your integration tests serially, if needed.

This setting is built into the test runner, as such it doesn't require special support from the test adapters for the different frameworks.

 

Search This Blog

Loading...

Most Reading