I moved from MSTest to MbUnit to achieve this. You can achieve parallelism at the test device level with MbUnit using ParallelizableAttribute. However, since test fixtures are generated from .Feature Gherkin files, I had to grab the SpecFlow source code and change the MbUnitTestGeneratorProvider class in the TechTalk.SpecFlow.Generator project to output ParallelizableAttribute. So you get something like this:
public class MbUnitTestGeneratorProvider : IUnitTestGeneratorProvider { private const string TESTFIXTURE_ATTR = "MbUnit.Framework.TestFixtureAttribute"; private const string PARALLELIZABLE_ATTR = "MbUnit.Framework.ParallelizableAttribute"; private const string TEST_ATTR = "MbUnit.Framework.TestAttribute"; private const string ROWTEST_ATTR = "MbUnit.Framework.RowTestAttribute"; private const string ROW_ATTR = "MbUnit.Framework.RowAttribute"; private const string CATEGORY_ATTR = "MbUnit.Framework.CategoryAttribute"; private const string TESTSETUP_ATTR = "MbUnit.Framework.SetUpAttribute"; private const string TESTFIXTURESETUP_ATTR = "MbUnit.Framework.FixtureSetUpAttribute"; private const string TESTFIXTURETEARDOWN_ATTR = "MbUnit.Framework.FixtureTearDownAttribute"; private const string TESTTEARDOWN_ATTR = "MbUnit.Framework.TearDownAttribute"; private const string IGNORE_ATTR = "MbUnit.Framework.IgnoreAttribute"; private const string DESCRIPTION_ATTR = "MbUnit.Framework.DescriptionAttribute"; public bool SupportsRowTests { get { return true; } } public void SetTestFixture(CodeTypeDeclaration typeDeclaration, string title, string description) { typeDeclaration.CustomAttributes.Add( new CodeAttributeDeclaration( new CodeTypeReference(TESTFIXTURE_ATTR))); typeDeclaration.CustomAttributes.Add( new CodeAttributeDeclaration( new CodeTypeReference(PARALLELIZABLE_ATTR))); SetDescription(typeDeclaration.CustomAttributes, title); }
If you compile this and use it, you will get parallelizable test equipment:
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.6.1.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [MbUnit.Framework.TestFixtureAttribute()] [MbUnit.Framework.ParallelizableAttribute()] [MbUnit.Framework.DescriptionAttribute("Test")] public partial class TestFeature {
The only problem with this is that you will need to make sure that the test devices do not conflict with each other. That is, a test from a single device adds or modifies a database row that breaks a test that runs at the same time. There are ways around this, but this is probably beyond your original question.
Alex
Alex webber
source share