Hi,

I think few days ago there was some information from Karel Piwko that we developed fully automatic functional tests when it comes to Cordova quickstarts (1) (hello world and shoot and share)

We think that it could be useful for developers as well. This tests the whole life cycle of the push from creation of UPS cartridge through building of the example to the functional test in a fully automatic manner from zero setup to push notification receive at mobile device you have connected to your notebook and it could be useful for developers in order to not execute it manually every time and set it up all over again.

By what I mean "fully automatic" is the following scenario:

1) Automatic creation of UPS cartridge on OpenShift right from our test, patched with this extension * (2), (3)
2) Because of the deployed extension to UPS in 1), we can login via REST and we do not need to change passwords so we can create application with some variant directly from our test script (4)
3) After this is done, quickstart example is downloaded from GH, Android SDK is installed locally at your PC, quickstart is filled with application and google credentials automatically and after that it is built
4) APK built in 3) is then used in functional test by Arquillian Droidium (5) which deploys that APK to physical device and in that test, we send push notification request to UPS
5) Once push notification comes to UPS, it sends it to GCM which in turn sends it to physical device and Droidium test asserts that the message really came and appeared on the mobile device.

It takes about 10 minutes, you have to have Android device attached to your PC since test will communicate with it. Time could be massively decreased when you do not expect new OS UPS instance to be created every time.

You execute it like this in https://github.com/aerogear/aerogear-unifiedpush-server-integration-tests repository

./gradlew test -Pprofile=helloWorldCordovaQuickstart \ 
    -PgoogleProjectNumber=<your  project number> \
    -PgoogleKey=<your google key> \
    -PopenShiftUsername=<email of your openshift account>
    -PopenShiftPassword=<password for your openshift account> \ 
    -PopenShiftCartridge=https://cartreflect-claytondev.rhcloud.com/reflect?github=aerogear/openshift-origin-cartridge-aerogear-push \
    -PopenShiftAppDirectory=aerogear-push

Similar process is executed with Shoot & Share demo where we send image to Facebook. All triggered by one shell command from integration tests and after that the above magic happens.

I case you want to use it and you struggle with it, feel free to ask me for guidance.

* unified-test-extension adds custom functionality to UPS cartridge, it adds fancy performance test endpoints where you can feed UPS instance with custom number of generated installations / categories / variants and so on. More to it, it can put proxy behind sender API so push notifications goes nowhere in the end but it seems like they were indeed sent from UPS point of view. This is particularly handy in test environment where you really do not want to send anything to APNS or GCM.

(1) https://github.com/jboss-mobile/unified-push-helloworld
(2) https://github.com/aerogear/aerogear-testing-tools/tree/master/unifiedpush-test-extension
(3) https://github.com/aerogear/aerogear-unifiedpush-server-integration-tests/blob/master/build.gradle#L354-L356
(4) https://github.com/aerogear/aerogear-unifiedpush-server-integration-tests/blob/master/build.gradle#L472-L543
(5) https://github.com/aerogear/aerogear-unifiedpush-server-integration-tests/blob/master/quickstartTests/aerogear-push-helloworld-cordova/src/test/java/org/jboss/aerogear/push/helloworld/cordova/test/AerogearPushHelloworldCordovaTestCase.java#L65-L85

--
Stefan Miklosovic
Red Hat Brno - JBoss Mobile Platform

e-mail: smikloso@redhat.com
irc: smikloso