How to test web services from the FSCRS (desktop/laptop edition)

This blog post will illustrate how to test web services on GNU/Linux workstations, using FSCRS, the eGov Testing Machine project.

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

First of all, you we will need to have a number of VirtualBox machines configured. If this is not the case, please refer to the Creating virtual machines chapter of the Testing Machine manual. These machines also has to be tm-vmm clients, so that tm-vmm will know how to interact with them. You can make this happen as per the instructions here. (Usually, it just includes a call to `tm-vmm --create-client-conf <machine-name>'.) Please note that SSH needs to be installed too, as this is how tm-vmm executes commands on VirtualBox machines.

Additionally, you need to make sure that the Java SDK (used to build our test application) as well as Ant (used to build and run the test application) are installed. If not, they can be installed like so (on Ubuntu):
 

    apt-get install openjdk-7-jre-headless ant openjdk-7-jdk

We are now ready to begin. Please clone the example repository that we have set up to make it easy for interested users to get started.
 
    git clone https://github.com/tis-innovation-park/tm-examples.git

This will create a directory `tm-examples' in your current directory. Let's change into the directory that contains a simple test project.
 
    cd tm-examples/eGov/simple

The project in this directory will check that a web service (URL) is available (returning a "200 OK" status). Run the test on your local machine by typing the following.
 
    ant -Dtm.url=https://testingmachine.eu/

A test report will be created in the directory `testng_output'. (If you want to change the directory, just append ` -Dtm.testngOutput=<directory>' to the Ant command.)
 

So far, so good... But what if we want to run automated testing using Selenium? Let's enter our Bolzano test project.
 
    cd ../bolzano


This is a test project, like simple one above, that integrates a larger battery of tests, as well as the Selenium library. To run its tests locally in Mozilla Firefox, type the following:
 

    ant -Dtm.seleniumDriver=FirefoxDriver

You will now notice that a Firefox window will open, and that the automated tests begins.
 

Once the tests finish, the report will be generated in the `testng_output' subdirectory. (Just as above, you can customize this path by setting the tm.testngOutput parameter.)

Now... Let's say that that we want these Bolzano tests over a number of tm-vmm clients (virtual machines and/or physical devices) that we have set up, and aggregate the test results somewhere. It just so happens that we have put an example script in the local directory that will let us do just that. First, however, we need to make sure that port forwarding is enabled for the VirtualBox machines, from host port 4444 to the guest port 4444:
 

 

Download Selenium server so that it can be accessed by the script.


    wget http://selenium.googlecode.com/files/selenium-server-standalone-2.37.0.jar

Now, let's run the script!

    tm-vmm --clients-exec script.sh "test0;test1;test2"
Now tm-vmm will start the `test0' client and execute the provided script, after which it will repeat the same action for the `test1' and `test2' clients. This will create a directory (`test_results') with test suite results - one result for every client. (Tip! You can leave out the client names if you want the script to run for all clients, instead of the ones that you specify.)

These tests can now be automated with a scheduler, and the script can easily be modified to, for example, move the test results to a certain machine using scp, or similar.

That's it for today. Coming up: How to include Android clients in the tests. smiley
Comments
No comments yet. Be the first.