One of the new features of the 2013 Q4 Secure CI Release was the inclusion of a testing framework, optimized for web based browser testing. I’m continuing to make a few updates to the testing framework, but more than anything I’ve been discovering more and more uses for it.
I’ve been working in the mobile testing world for most of this year, assisting developing a course, and experimenting with a multitude of tools. Possibly the most interesting aspect of this space is the overall immaturity of it, and lack of robust tools available. Much like the internet in it’s early days, few tools exist that can test across multiple devices, and even fewer work well. The mobile application world is divided up into two kinds of applications, mobile web apps and native apps. Because mobile web apps are applications design for mobile devices and run entirely in a browser, we can leverage some of the more robust tools out there for desktop browser testing: in this case, we’ll be examining the SecureCI Testing Framework.
For this tutorial, we want to see how to execute tests from our machine onto either a tethered, or emulated device. After our tests are written, follow the detailed instructions outlined in the initial testing framework post to ensure they run properly on a browser locally. First we want to run the tests using HtmlUnit. Navigate to the project directory and run the below command:
The console will start outputting information from the ant call. When the test completes, a BUILD FAILED or BUILD SUCCESSFUL message will show in the console. Next run the tests using Chrome or Firefox, by executing this command
The console output will start and several Chrome or Firefox windows may open, depending on your number of tests. You can watch the tests execute from the browser. Once complete a BUILD SUCCESSFUL or BUILD FAILED message will be shown in the console. Using the Chrome or Firefox driver allows screenshots to be captured a verification points to show what the page looked like when the step passed or failed. Screenshots are not available in the HtmlUnit test run.
Now let’s try running these same tests on the mobile emulator, but first we need to do a little configuration. We’ll walk through these steps using an android device, but the same could be similarly tailored for an apple one. Download and install the Android Device Bridge. On linux, it is as simple as running the command
sudo apt-get install adb
On Windows it is a little more complicated, as you must download the package, unzip it to a folder, and then add the directory to your path. Once this is done, either launch an emulator (left up to the user as an exercise) or plug in your phone to your machine via usb, and on the device choose tethered mode. Once everything is up and running/connected, determine the devices’s serial-ID
Next we’ll want to Install the android server on it
adb -s [serialId] -e install -r android-server.apk
Then we need to start Selenium on the device
adb -s shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
Finally forward port 8080 from your machine to the device, so that the tests can connect to the emulator
adb -s forward tcp:8080 tcp:8080
Now we can execute our tests. Run the tests using Android, by executing this command
The console output will start and you should see tests launch on your device. Be patient, this is MUCH slower. Once complete a BUILD SUCCESSFUL or BUILD FAILED message will be shown in the console. Results will be generated similarly to the Chrome and Firefox tests.
And there you go. This framework provides the simplicity of reporting and screenshots that we had on our desktops, pushed into the mobile web world. Questions, comments, suggestions? Leave them after the jump!