Best practice for testing apps is to test against staging backend servers that do not contain live information. Appium always encourages the ability to test the exact same app which you publish to the app store, so compiling different versions of your app (one for testing one for publishing) is not recommended.
There is a good solution for testing against staging backends that doesn’t involve compiling separate apps:
Appium has the ability to pass environment variables to the apps it launches on both iOS and Android. The apps can then check the environment variables when connecting to backend servers.
On iOS: Start your Appium test with an extra desired capability: processArguments
. This capability takes a string of extra arguments to pass to Instruments. Instruments takes environment variables using a -e
flag. eg: processArguments: "-e FOO bar -e BAZ qux”
. These environment variables can be accessed in the iOS application as arguments: -[NSProcessInfo arguments]
see: https://github.com/appium/appium-instruments/issues/11
On Android: Various means are available. Check out these desired capabilities: appActivity, intentAction, intentCategory, optionalIntentArguments. see: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md