VS2015 Update 1 brings (back) parallel test execution

Yesterday I’ve installed the new VS2015 update and tried to make my machine talk to my win10 (IoT core) Raspberry PI. It didn’t help but that’s a story for another blog post – spoiler: it was a problem with my laptops Ethernet port.

After the dust settled I’ve started reading about the new goodness that was just added to my trusty Visual Studio and found out that Microsoft has decided to give us the parallel test execution.

It all started back in the long forgotten Visual Studio 2010. Back then we had a great feature called parallel test execution. It did exactly that – reduce run speed by utilizing several cores to run tests – it was well hidden but for those of use who know where to enable it – it worked like a charm – as long as other tools, especially your Mocking framework of choice supported multi threading.

Then came VS2012 and the ability to run unit tests side by side disappeared… you could use it but for the price of using the old soon to be legacy test runner.

Since I liked the fact that my test run took less time I was happy to see that the feature I liked came back.

Enabling parallel tests is simple – first create a new test.runsetings – don’t look for a template (because there is none), just add a new xml file and rename it.

For parallel tests you just need the file to contain the following lines:




0


For the value of MaxCpuCount  use the number of threads you want to use (usually 1 for sequential run), or instead ‘0’ or a number greater of the number of your machine logical core (please use ‘0’).

Look under Test menu for “Select Test Settings File” and choose the newly minted (test settings) file.

image

For more information of what the test settings file can do for you – read this MSDN page.

Now when running the tests you’ll see improvement it the time it takes for them to finish.

mstest_parallelUntitled

I did notice that it took longer for the tests to start running and there’s a barely noticeable delay at the end of the run but other than that – parallel tests!

As you can see the runner runs assemblies in parallel so if you have a lot of tests in one assembly – you might not benefit from this feature, please consider splitting your tests (and probably production code as well).

I still need to check if (and which) mocking frameworks would work with this new(ish) test execution.

 

Happy coding…

2 thoughts on “VS2015 Update 1 brings (back) parallel test execution

  1. I am curious on this post. When I try running against the .runsettings file, only one test in ran per assembly(dll). So if I have 2 unit test projects, then both will run in parallel, but only 1 test is executed at a time, which is different than your GIF. Did you do anything else to your .runsettings file?

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s