1

How do you test a hybrid application when your requirement is to sign off and ship the very same package? You have a single hardcoded URL your AJAX calls are going to go to, but actually this endpoint needs to be different in test and production environments.

  • Override the hosts file is not an options because it would require to root all test devices.
  • Serve and host custom DNS server or HTTP proxy is an overkill.
  • Have an application option is against the requirements, the end users can not be exposed to such a setting.
  • Have a cookie to optionally override the URL would work but how to I add a cookie manually to a hybrid app running on a tablet?
  • Have a local storage setting to optionally override the URL would work but how to change local storage manually?

Is there a way to have but hide an application configuration option, setting from the end user?

Testing is performed on iOS tablet running a native app package.

sibidiba
  • 6,270
  • 7
  • 40
  • 50

1 Answers1

2

If you really really want to ship the exact same code all the time, you could easily use local storage. In your app:

if(!localStorage.getItem('env')) localStorage.setItem('env', 'production');
switch(localStorage.getItem('env') {
    case 'testing': endpoint = 'http://testserver'; break;
    case 'production': endpoint = 'http://productionserver'; break;
}

Then just open your browser console and type:

localStorage.setItem('env', 'testing');

You might not be able to open a console on mobile browsers or inside Cordova, but if you really need that: rethink the "same package" thing. I can't think of any valid reason why you would not want to do different testing and production builds.

jgillich
  • 71,459
  • 6
  • 57
  • 85
  • I have seen numerous times where a "trivial change", a "configuration-only change", a "can't break anything change" has introduced fatal issues in prod. It makes really sense to mandate to sign-off and release precisely the same asset. Your mileage might vary depending how business critical (think of money and clients) your subject is. I'm looking into options how to open console on iOS tablet... https://github.com/phonegap/phonegap/wiki/Debugging-in-PhoneGap – sibidiba May 15 '14 at 01:56
  • Your suggestion to use localstorage in combination with remote console could bear a solution: http://stackoverflow.com/questions/4022152/how-to-see-the-javascript-errors-of-phonegap-app-in-xcode – sibidiba May 15 '14 at 02:23