Search code examples
tfsmspec

How do I run MSpec tests in parallel on TFS 2013?


I'm trying to get a bunch of MSpec tests to run on multiple cores in TFS 2013. It doesn't appear to do it out of the box. It can run MSpec, but only in sequence and it takes a over an hour.

I am following this guide, but in step 4 he says replace the Foreach Xaml element with ParallelForEach to get the tests to run in parallel. I downloaded the default build template in TFS 2013. It is a lot simpler, but it doesn't have this tag.

It has:

<mtba:RunAgileTestRunner 
  DisplayName="Run VS Test Runner" 
  Enabled="[Not AdvancedTestSettings.GetValue(Of Boolean(&quot;DisableTests&quot;, false)]"
  TestSpecs="[AutomatedTests]"
  ConfigurationsToTest="[ConfigurationsToBuild]" />

Solution

  • The default MSpec test runner cannot run tests in parallel. That's why you see the reimplementation of a parallel test runner.

    I doubt that TFS is implementing an MSpec test runner from the framework source code (although that would be possible). That parallel test runner is using internal classes, like ISpecificationRunner, and running them in parallel.

    Your only options, if you must stick with MSpec and TFS, are

    • Split your tests into multiple projects/assemblies and feed them to a TFS parallel task that shell-executes the default test runner

    • Use a TFS shell-execute task to run your tests through the parallel runner