Roland Oldengarm - Independent IT Contractor

Living in the coolest little capital Wellington, New Zealand!

Category: Mobile Apps

How to automatically test your non-Angular Cordova or Ionic App

Part of building any application is testing. I am focusing only on tests executed by the developer, so the first stage in any development cycle. The first option is to do this manually. While this works for most usecases, it has some major disadvantages:

  • It is time consuming.
  • You can’t run all the manual tests after each change.

When a developer does a manual test, he only confirms that the change did what it had to do. To assure it did not break anything else, in most cases he will do a quick regression test, but that won’t cover all possible regression issues.

We are building a Cordova / Ionicapp, with some complicated, time consuming use cases like logging in, logging out, adding items to a list, etc. Any change we make may cause a regression. We do have some unit tests to cover certain services and controllers, but that does not cover everything.
So, we have decided to use end-to-end automated tests to be sure that before each release, the major part of the app is still working as expected. Any bugs detected with these tests can be fixed by a developer straightaway. If it would be detected by our testers, or even worse by the client in UAT, this would make it much more expensive to fix.

I have spent some time to figure out what the best way of doing this is. I couldn’t find a lot of working documentation and examples to set up automated user testing with a Cordova / Ionic mobile application.

Continue reading

ADAL Cordova, Android => Loading?

We are developing an app for Cordova. It will authenticate against Azure AD, and we are using the ADAL library for Cordova. To test this is working, we did a proof of concept, and thas was all working fine.

When testing it in our “production” app, it did not work. When kicking off the authentication with this code:

var ctx = new Microsoft.ADAL.AuthenticationContext(authority);
ctx.acquireTokenAsync(resourceUrl, appId, redirectUrl).then(function (authRes) {
//todo
console.log(authRes.accessToken);
});

… it did no longer work on Android. On Windows 8.1 it was fine. On Android it opened a new window for the authentication screen, but it was stuck at “Loading”. Nothing in the JavaScript console either. So, I stripped all the includes out of the HTML, until I finally had the identical HTML + JS as the working proof of concept.

So, it must be something in the Android settings. I compared them, and it turned out “Keep running” was turned off in the “Production” app, and turned on in the working POC. I enabled that and now it is working… This setting can be found by opening config.xml => Android. In the XML it is:

<preference name=”KeepRunning” value=”True” />