Hybrid app testing using dynamic DNS

Hybrid apps simplify implementing cross-platform mobile applications in many ways.  You only need to write the HTML once, and it should work on all platforms.  However, you still need to test those platforms.

At Wellmo, we do most of our development on local environments using a browser, and test the functionality on phones afterwards.  This poses a problem:  We have a bunch of test devices, but each time you’d want to test on one, you need to install a new native client pointing to the appropriate environment (often your own local environment).  What’s worse is that iOS applications can be developed / deployed only on a Mac and Windows Phone applications only on Windows.

We solved this issue by using dynamic DNS addresses for each device, which allows any developer to point any device at any environment with a single command.

The setup

We have named each test device, and created a corresponding dynamic DNS address for each device. Each device has a version of Wellmo installed which points to the dynamic DNS address.  This way we can simply point the dynamic DNS address to different environments, and the app will start using that particular environment.

This has greatly simplified the process of testing on devices.  It works fine even against local environments within a private network, as long as the server and device are on the same wireless network.  You just set the dynamic DNS to point to your internal IP address, and you’re good to go.

For updating the DNS addresses, I wrote a shell script that allows any developer to update any dynamic DNS host to whatever environment (or their local IP).  For example, saying noip android dev would point the device named ‘android’ to the ‘dev’ environment.  Alternatively, noip android would point it against my local environment.

The script is available as a Gist.  There’s a few configuration parameters at the beginning.  After that you can run it without arguments to get a short help.

We ended up using noip.com, which provides 25 dynamic DNS addresses for $20/year.  This is negligible cost compared to the benefit.


There are a few problems you need to be aware of when using this method.

First, phones cache DNS lookups quite aggressively.  Typically, when you switch an address you have to turn Wi-Fi off and on again to make sure any DNS cache is purged on the device.  It also takes some time for the DNS update to propagate — with no-ip it’s about 1-1.5 minutes.  HTTP caches, such as the cache manifest, need also to be taken into account.

Second, your server must work properly regardless of what host name is used.  This may be a problem if you use virtual hosts or if you protect against CSRF attacks by validating the Origin header.  You may need to configure additional virtual hosts or create a flag to disable the CSRF check in development environments.

Thirdly, you can’t change the port or protocol your app is connecting with.  We have configured all our development environments to answer also to port 8080, so we can easily switch between local and deployed environments.  However, you can’t switch between SSL and non-SSL servers using this method (and any SSL certificates will be invalid for the domain anyway).  Therefore this method does not work for testing against production.

With these caveats in mind, this has simplified our testing process to the point that there’s no excuse for not testing on devices while developing features.

This entry was posted in Hybrid apps, Testing and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s