Run NUnit Tests in Parallel
On BrowserStack, you can run multiple NUnit tests at the same time across various browser, device, and OS combinations. This is Parallel Testing. Parallel Testing gives you the same benefits as running a multi-threaded application.
With Parallel Testing, you can run the same test on different browser/device combinations i.e. cross-browser testing, or run different tests on the same or different browser/device combinations. Parallel Testing will help you reduce the run time of your test suite, resulting in faster build times and faster releases.
Run sample test in parallel
- Clone the nunit-browserstack sample repo on GitHub, if not already done:
git clone https://github.com/browserstack/nunit-browserstack.git
-
Open the solution
NUnit-BrowserStack.sln
in Visual Studio. - Setup your credentials and browser/devices where you want to run your test, in the
App.config
file as shown below:
nunit-browserstack/NUnit-BrowserStack/App.config<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="capabilities"> <section name="parallel" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </sectionGroup> <sectionGroup name="environments"> <section name="chrome" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <section name="firefox" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <section name="safari" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <section name="edge" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </sectionGroup> </configSections> <appSettings> <add key="user" value="YOUR_USERNAME" /> <add key="key" value="YOUR_ACCESS_KEY" /> <add key="server" value="hub-cloud.browserstack.com" /> </appSettings> <capabilities> <parallel> <add key="browserstack.debug" value="true" /> </parallel> </capabilities> <environments> <chrome> <add key="browser" value="chrome" /> </chrome> <firefox> <add key="browser" value="firefox" /> </firefox> <safari> <add key="browser" value="safari" /> </safari> <edge> <add key="browser" value="edge" /> </edge> </environments> </configuration>
Following are the test cases for running the tests in parallel with NUnit.
[TestFixture("parallel", "chrome")] [TestFixture("parallel", "firefox")] [TestFixture("parallel", "safari")] [TestFixture("parallel", "edge")] [Parallelizable(ParallelScope.Fixtures)] public class ParallelTest : SingleTest { public ParallelTest(string profile, string environment) : base(profile, environment) { } }
-
You can now run your tests in parallel on BrowserStack using the following steps:
- Build the solution in Visual Studio
- Run tests with fixture
parallel
from Test Explorer
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!