# How to run parallel test on multiple ios physical device

**URL:** <https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665>\
**Category:** Support\
**Created:** [December 7, 2016, 4:24pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665 "2016-12-07T16:24:36Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chockie](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@Chockie](https://discuss.appium.io/u/Chockie)\
**Post date:** [December 7, 2016, 4:24pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/1 "2016-12-07T16:24:36Z")

</div>

I try to create new sessions with different port to run parallel test on two ios physical devices with testng. But it always happen that, when the first device starts the second one will crash on starup, or when the second one starts the first one does not act any more, it shows the instrument never checked in… I really want to run parallel test on multiple devices on one mac, but I still can not find out what’s wrong.  
My environment:  
mac: mac os x 10.12.1  
iphones: iphone6(ios 9.2) iphone6s(ios 9.3)  
appium: 1.5.3

---

<div class="post-metadata">

**Author:** ![SireeshaSimakurthy](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@SireeshaSimakurthy](https://discuss.appium.io/u/SireeshaSimakurthy)\
**Post date:** [December 8, 2016, 11:55pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/2 "2016-12-08T23:55:43Z")

</div>

I think IOS Parellel execution is not possible (limitation from Apple) 😞

Correct me If I am wrong

---

<div class="post-metadata">

**Author:** ![Sethu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@Sethu](https://discuss.appium.io/u/Sethu)\
**Post date:** [December 9, 2016, 5:01pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/3 "2016-12-09T17:01:47Z")

</div>

@SireeshaSimakurthy Nope we can run do parallel execution on real devices with appium/selenium  
Limitation is you cant run ios simulators in parallel.

---

<div class="post-metadata">

**Author:** ![SireeshaSimakurthy](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@SireeshaSimakurthy](https://discuss.appium.io/u/SireeshaSimakurthy)\
**Post date:** [December 9, 2016, 5:44pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/4 "2016-12-09T17:44:40Z")

</div>

@Sethu, Thanks for correcting me… Can you please share details on how to do parallel execution on IOS Real device using appium / Selenium.

---

<div class="post-metadata">

**Author:** ![Chockie](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@Chockie](https://discuss.appium.io/u/Chockie)\
**Post date:** [December 11, 2016, 3:51am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/5 "2016-12-11T03:51:22Z")

</div>

Hi, I made it with testng and start different appium services. Below is how I implement it.  
@BeforeClass  
@Parameters({ “tempDir” })  
public void setup(final String tempDir) {  
this.service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()  
.withAppiumJS(new File("/Applications/appium.app/Contents/Resources/node\_modules/appium/build/lib/main.js"))  
.withArgument(GeneralServerFlag.TEMP\_DIRECTORY, tempDir)  
.withArgument(GeneralServerFlag.SESSION\_OVERRIDE)  
.usingAnyFreePort()  
.withArgument(GeneralServerFlag.LOG\_LEVEL, “info”));  
this.service.start();  
}

```
@BeforeMethod
@Parameters({ "udid", "deviceName", "platformVersion" })
public void beforeMethod(final String udid, final String deviceName, final String platformVersion) {
	this.driver = new AppiumIOSDriver(service.getUrl().toExternalForm(), udid,
			deviceName, platformVersion);
}
```

---

<div class="post-metadata">

**Author:** ![Wafe\_is\_7](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/e47774/32.png) [@Wafe\_is\_7](https://discuss.appium.io/u/Wafe_is_7)\
**Post date:** [December 11, 2016, 5:44pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/6 "2016-12-11T17:44:29Z")

</div>

you need to start appium with tmp folder for each device for example:  
appium … /tmp/iphone6  
appium … /tmp/ipad

---

<div class="post-metadata">

**Author:** ![Chockie](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@Chockie](https://discuss.appium.io/u/Chockie)\
**Post date:** [December 13, 2016, 1:32am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/7 "2016-12-13T01:32:08Z")

</div>

Yes. But it still will crash after running a few test cases. When I run the code with testng, the error will occur: abnormal instrument termination.

---

<div class="post-metadata">

**Author:** ![Wafe\_is\_7](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/e47774/32.png) [@Wafe\_is\_7](https://discuss.appium.io/u/Wafe_is_7)\
**Post date:** [December 13, 2016, 9:40am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/8 "2016-12-13T09:40:37Z")

</div>

1. Write how you start appium with different devices
2. Need to see logs

---

<div class="post-metadata">

**Author:** ![Chockie](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@Chockie](https://discuss.appium.io/u/Chockie)\
**Post date:** [December 15, 2016, 2:21am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/9 "2016-12-15T02:21:16Z")

</div>

logs only output the error: abnormal instrument termination(the server did not provide any trace information)…  
I have set show ios system log flag.

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kinger](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@Vibhu\_Kinger](https://discuss.appium.io/u/Vibhu_Kinger)\
**Post date:** [December 22, 2016, 8:01am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/11 "2016-12-22T08:01:11Z")

</div>

One tweek that you do is…You can Have your Appium Server started on different port & bootstrap ports inside your test beforetest annotations. Therafter you can initialize Appium Driver instance inside beforemethod annotation. Use can make use of Observer & Protype patterns to facilitate use & upgrade configurations inside beforemethod. Also use different test tag for each device ios/android devices. You need not use Appium Grid but still you will be able to execute test suite in parallel. Do revert in case of any ambiguity, will post working code if required.

Regards  
Vibhu Kinger

---

<div class="post-metadata">

**Author:** ![Chockie](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@Chockie](https://discuss.appium.io/u/Chockie)\
**Post date:** [December 26, 2016, 3:01am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/12 "2016-12-26T03:01:04Z")

</div>

Thanks. I made it work with testng and started different appium service. I’ve my code. And I want to know how you figure it out. Could you post part of your code?

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kinger](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@Vibhu\_Kinger](https://discuss.appium.io/u/Vibhu_Kinger)\
**Post date:** [February 2, 2017, 7:53am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/13 "2017-02-02T07:53:11Z")

</div>

Idea is to execute objects in different appium threads. Once using different Test tags from your TestNG & set parallel="“test” in your testng. Initialize complete objects of classes that you use in your framework & store them in a key value pair data structure. Hence for every test tag in testng xml you will end having objects for that configuration stored. Therafter your Observer Design Pattern takes over as inside every before method annotation you use updateconfiguration & load objects for that configuration from key-value pair. I hope this solves your problem!

---

<div class="post-metadata">

**Author:** ![KalveeduVJ](https://discuss.appium.io/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@KalveeduVJ](https://discuss.appium.io/u/KalveeduVJ)\
**Post date:** [February 25, 2017, 2:59am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/14 "2017-02-25T02:59:19Z")

</div>

Hi @Vibhu_Kinger,

Is it possible for you to provide step by step guidance on how to achieve this ? Basically I want to run more than one iOS devices in parallel.

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kinger](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@Vibhu\_Kinger](https://discuss.appium.io/u/Vibhu_Kinger)\
**Post date:** [March 6, 2017, 11:35am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/15 "2017-03-06T11:35:05Z")

</div>

Inside @BeforeTest annotation create objects for all of your framework classes for.eg inside code below i have a class named automationdriver inside constructor of which i initialize objects of all of my framework class  
Like:  
public class AutomationFactory  
{  
HashMap\<String, Object\> hmConfiguration=new HashMap\<String, Object\>();  
public AppiumDriver driver;  
public BaseInitializerHub objBaseInitializerHub;  
public ObserverSubject objSubject;  
public AutomationDriver automationDriver;

@BeforeTest/ **/Here you create objects of framework classes, store them in a hashmap also here you attach objects with the resp. subject using observer pattern**  
public void beforeTest()  
{  
attachSubjects(testContext);  
new AppiumSessionManager().startAppiumServer(IP,PORT,deviceName,logfilepath,bootstrapport);

AutomationDriver automationDriver=initializeAutomationDriver(os,logpath, PORT,appendername,configurationMap.get(InitializerConfig\_),UDID\_,deviceGroup,InitializerConfig\_);  
hmConfiguration.put(configuration, automationDriver);  
}

public void attachSubjects(ITestContext testContext)  
{  
objSubject=new ObserverSubject();//make these global  
for (ITestNGMethod method : testContext.getAllTestMethods()) {  
method.setRetryAnalyzer(new MyRetryAnalyzer(objSubject));  
}  
new AppiumHelper(objSubject);//make these global  
new Log(objSubject);//make these global}

}

@BeforeMethod\*\*//Here you load the configuration which you want to use\*\*  
public void beforemethod()  
{  
automationDriver=(AutomationDriver) hmConfiguration.get(confiration);  
driver=new AppiumSessionManager().initializeAppiumDriver(deviceName\_, UDID\_, platformVersion\_, URL\_,hubHost,hubPort,os,bundleId);  
automationDriver.appiumDriver=driver;  
objSubject.setAutomationDriverState(automationDriver);

}

In case you create all framework objects in your test scripts than you do not need these but in case you have helpers which internally use appiumdriver than this way you can achieve parallel execution.

---

<div class="post-metadata">

**Author:** ![ANKUR\_SATIJA](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@ANKUR\_SATIJA](https://discuss.appium.io/u/ANKUR_SATIJA)\
**Post date:** [October 10, 2017, 12:13pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/16 "2017-10-10T12:13:49Z")

</div>

Hi All,

Can i Start 2 instance of iOS appium Desktop application on same MAC?

---

<div class="post-metadata">

**Author:** ![Free\_Automation](https://discuss.appium.io/user_avatar/discuss.appium.io/free_automation/32/3493_2.png) [@Free\_Automation](https://discuss.appium.io/u/Free_Automation)\
**Post date:** [October 25, 2017, 1:46pm UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/17 "2017-10-25T13:46:55Z")

</div>

You can watch this [https://youtu.be/vXpskMkytD8](https://youtu.be/vXpskMkytD8)

---

<div class="post-metadata">

**Author:** ![pragassp](https://discuss.appium.io/user_avatar/discuss.appium.io/pragassp/32/4287_2.png) [@pragassp](https://discuss.appium.io/u/pragassp)\
**Post date:** [March 14, 2018, 11:15am UTC](https://discuss.appium.io/t/how-to-run-parallel-test-on-multiple-ios-physical-device/13665/18 "2018-03-14T11:15:38Z")

</div>

Please share relevant things …the video doesnt help for parallel ios device testing.
