Parallel Execution using NUnit

Hi, I want to run parallel tests in iOS and Android devices and I am trying to use NUnit and Visual Studio for doing it.

I know Appium Studio can see two devices and, if I am not wrong, parallel execution on physical connected devices is only possible by using an IDE.

I’ve seen a tutorial for TestNG but I need to use NUnit and Visual Studio.
NUnit 3 allows parallel execution and so the thing should be possible.

Has someone already tried?

I compile all our test with Visual Studio so every test is packed inside an EXE file. Then you can launch in parallel.

I don’t use NUnit or MSTest, only pure C# code

Hi, thanks for your answer.

How many ports do you use for your test?

By default Appium Studio sees the device on this port
http://localhost:4723/wd/hub

and I was wondering if it is possible to run two ports at a time.
Apparently it is not possible, on community edition at leastCapture

So how did you manage with one port enabled and two devices?

You’re right, you cannot use more than one port but you have two execution agents.

I use AS to send tests to two iPad, the only thing of the test I change to send to one or another iPad is the UDID of the device and the device name. Same way if you use two Android devices or one Android and one iOS.

This is a test copied directly from AS, if you compile this changing only the device name and UDID you can run it in parallel using two iOS devices. (Of course it will fail unless you change the item to find and click)

The agent port doesn’t change but the Community license allows up to two simultaneous executions. If you need more executions then you must purchase them apart.

namespace Experitest
    {
    [TestFixture]
    public class Untitled
    {
        private string reportDirectory = "reports";
        private string reportFormat = "xml";
        private string testName = "Untitled";
        protected IOSDriver<IOSElement> driver = null;

        DesiredCapabilities dc = new DesiredCapabilities();

        [SetUp()]
        public void SetupTest()
        {
            dc.SetCapability("reportDirectory", reportDirectory);
            dc.SetCapability("reportFormat", reportFormat);
            dc.SetCapability("testName", testName);
            dc.SetCapability(MobileCapabilityType.Udid, "change_this_UDID_for_every_device"); // <-- Device UDID 
            driver = new IOSDriver<IOSElement>(new Uri("http://localhost:4723/wd/hub"), dc);
        }

        [Test()]
        public void TestUntitled()
        {
            driver.ExecuteScript("seetest:client.setDevice(\"ios_app:IPADAIR\")"); // <-- Device Name
            driver.FindElement(By.XPath("//*[@xpath='test']")).Click(); // <-- Item to check and click.
        }

        [TearDown()]
        public void TearDown()
        {
            driver.Quit();
        }
}

Hi, sorry I did not answer before.

I just tried running the solution on two devices in parallel and it works as you explained;
keeping the same port (4723) and changing the device identifier.

The only thing to set is adding this line
[assembly: Parallelizable(ParallelScope.Fixtures)]
in AssemblyInfo.cs of the NUnit Test solution.
Details here
https://templecoding.com/blog/2016/02/29/running-tests-in-parallel-with-nunit3/

So thank you very much.

great! :+1: :grinning: