I have an automation suite for our native apps on Android and iOS created using Cucumber, Calabash, and Ruby. I'm utilizing a Page Object Pattern to allow for our project to be cross-platform. At runtime, we can specify to load the iOS or Android profile. Fairly standard stuff for native app automation using these tools.
Each scenario requires me to log in with a username and password which I've specified directly in the feature file.
Given I am on the start page
When I tap "sign_in"
And I login with "user1" and "password1"
This works great provided I'm only testing one device at a time. When I log in with "user1" and check that the account is in a specific state (i.e. the shopping cart is empty), then perform and action (add something to the cart) then check that the account state reflects my action (that item appears in the cart), everything works fine.
Problem: When I have two or more devices running side by side that are both using "user1", the first device will oftentimes put the account in a certain state (something is added to the cart) before the second device gets a chance to finish logging in. So when the second device logs in with "user1" the account is in an unexpected state (the item is already added to the cart from the first device) and that test fails on the second device.
Solution: Utilize different accounts for devices running concurrently. Device 1 will log in as "user1" and device 2 will log in as "user2". Separate accounts on different devices don't lead to the account state conflicts caused by actions taken by another device in the pool.
Question: How and where do I specify these different user accounts and how can each device know which user account to use? Is there a separate config file or helper module in my framework that I need to create?