How to test web services from the FSCRS (smartphone/tablet/TV edition)

This is a follow-up to How to test web services from the FSCRS (desktop/laptop edition), and will show how to test web services on Android smart phones, tablets and Smart TVs, using FSCRS, the eGov Testing Machine project.

Update: We have published a complementary screencast to this blog post here.

Analogous to the preparations in the previous how-to, please make sure you have tm-vmm and your Android environment set up (please refer to the Getting ready for eGov testing post), as well as one or more Android virtual clients configured. If you need to set up Android devices, please refer to the Android section of the Creating virtual machines chapter of the Testing Machine User Guide. Like with the previous blog post, these machines also has to be tm-vmm clients. Again, the instructions to make this happen can be found here. This tutorial assumes that we have three Android clients, `test2' (a phone), `test3' (a tablet), and `test4' (a Google TV).

You will also need to allocate memory on the emulated SD card in order for Selenium to work correctly on the Google TV device. Start the Android Virtual Device manager by running `android avd', select the Google TV AVD, click "Edit...", and set an SD card size like in the image below.
 


Let's get started! If you have not already checked out the tm-examples repository, please do so by issuing the Git command below.

git clone https://github.com/tis-innovation-park/tm-examples.git

Change the directory into the Bolzano eGov testing project, where we find the Selenium-based test suite to run.

cd tm-examples/eGov/bolzano

In order to run the test on the device, we will need to install a server that we can talk to. We fetch the Android Selenium server APK for this.

wget http://selenium.googlecode.com/files/android-server-2.21.0.apk

Our test script will install the APK file, execute the (just installed) WebDriver app on the device, set up the port forwarding needed, and initialize the test suite. Thanks to the convenient interface of tm-vmm, this can be done in the script with just four lines of Bash, as can be seen below. (You don't need to run these lines yourself, they are only here to demonstrate how the script works.)
 
tm-vmm --install-app $CLIENT_NAME android-server-2.21.0.apk
tm-vmm --client-exec $CLIENT_NAME "am start -n org.openqa.selenium.android.app/.MainActivity"
adb -s $ANDROID_DEVICE forward tcp:8080 tcp:8080
ant -Dtm.seleniumDriver=AndroidDriver -Dtm.testngOutput=test_results/$CLIENT_NAME-$DATE

In order to iterate through the phone, tablet, and Google TV clients, just run the following:

tm-vmm --for-clients-run script.sh "test2;test3;test4"

The tests should now be running. This is what it looks like on a Google TV device:
 

Just like with the previous blog post, the test results are saved in `test_results/$CLIENT_NAME-$DATE'. The `$CLIENT_NAME-$DATE.xml' file in your local directory will contain further information about the test, such as whether it succeeded. See below.
 
<target name="test4">
  <start-time>2013-12-16 19:07:51</start-time>
  <client-start>0</client-start>
  <client-up>0</client-up>
  <client-ssh>-1</client-ssh>
  <test>
    <name>Bolzano</name>
    <result>0</result>
    <logfile>/home/jonkri/tm-examples/eGov/bolzano/test_results/test4-2013-12-16/html/index.html</logfile>
  </test>
  <client-stop>0</client-stop>
  <stop-time>2013-12-16 19:07:16</stop-time>
</target>

That's it for today. Enjoy your Android web testing!
Commenti
Nessun commento. Vuoi essere il primo.