Skip to content

Selenium Parallel tests execution

Jakub Raczek edited this page May 12, 2016 · 16 revisions

Our framework supports parallel test execution, how to enable it in your test project depends on selected Unit framework:

With Objectivity.Test.Automation.Tests.NUnit

you have to add the attribute to the test classes ParallelScope.Fixtures indicates that fixtures may be run in parallel with one another.

namespace Objectivity.Test.Automation.Tests.NUnit.Tests
{
    using System.Collections.Generic;

    using global::NUnit.Framework;

    using Objectivity.Test.Automation.Common;
    using Objectivity.Test.Automation.Tests.NUnit.DataDriven;
    using Objectivity.Test.Automation.Tests.PageObjects.PageObjects.TheInternet;

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class HerokuappTestsNUnit : ProjectTestBase
    {
        [Test]
        public void BasicAuthTest()
        {
            var basicAuthPage =
                new InternetPage(this.DriverContext).OpenHomePageWithUserCredentials().GoToBasicAuthPage();

            Verify.That(
                this.DriverContext,
                () =>
                Assert.AreEqual(
                    "Congratulations! You must have the proper credentials.",
                    basicAuthPage.GetCongratulationsInfo));
        }
    }
}
namespace Objectivity.Test.Automation.Tests.NUnit.Tests
{
    using global::NUnit.Framework;

    using Objectivity.Test.Automation.Tests.PageObjects.PageObjects.TheInternet;

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class JavaScriptAlertsTestsNUnit : ProjectTestBase
    {
        [Test]
        public void ClickJsAlertTest()
        {
            var internetPage = new InternetPage(this.DriverContext).OpenHomePage();
            var jsAlertsPage = internetPage.GoToJavaScriptAlerts();
            jsAlertsPage.OpenJsAlert();
            jsAlertsPage.AcceptAlert();
            Assert.AreEqual("You successfuly clicked an alert", jsAlertsPage.ResultText);
        }
    }
}

More info about NUnit Framework Parallel Test Execution

With Objectivity.Test.Automation.Tests.MsTest

how set parallel test execution depends on Visual Studio version you using or test runner version. One of solution is to use Testsettings.testsettings file.

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local" id="164f37f6-b408-4a43-9caa-97fe6ccd4dc4" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <Deployment enabled="false"/>
  <Execution parallelTestCount = "2">
	<TestTypeSpecific />
    <AgentRule name="Execution Agents">
    </AgentRule>
  </Execution>
</TestSettings>

More details can be find here how to run unit tests mstest in parallel

Please notice that Selenium IEDriver doesn't support test execution in parallel.

Clone this wiki locally