Tuesday, July 13, 2010

When to automate? is equally important

Dhanasekar S's  recent blog which differentiates between importance of manual testing and automation testing triggered this blog. With all my automation experience I can say that there is one thing important in automation according to me.
That is 'When to Automate?'
As James Bach says "Test automation is any use of tools to aid testing". That is very much true, but to identify what are those tools and when to automate  is usually difficult job for me .So I came up with the following parameters to find out when to automate .  
  1. When I am doing any manual task repetitively , e.g.
    1.  Creating data set for my application.
    2.  Running same configuration every time after preparing the setup.
    3.  Even doing ssh(remote login) to same IP  frequently.
  2.  Smoke Testcases which need to be run  with every new build:- This case is also kind of a repetitive task where you need to run scripted testcases every time a new build comes. It is good to automate these as they give you more time to explore new areas in your application.


    I  would like to cite an example related to case 1 .
    Recently , I started writing testcases  for new features using mindmaps. Mind maps gives better overview of my testcases and their coverage.It also helps me getting quick review from development team .

    But the issue is when I need to write all my testcases again to my test management tool ie Testopia. Let me tell you about Testopia ,Testopia is awesome test management tool from mozilla which provide api's over XML::RPC  to update /modify  testcase database. 
    Anyways my above task was repetitive and obviously  boring which provoked me to  write a perl script to  parse test cases from mind map's file and directly update in Testopia. "Same script can be used in future" was also an another trigger point to automate the task. Scripts to achieve the above task got ready in just 45 minutes  and I updated 100+ testcases with the script to Testopia. In the above scenario I was not told to automate.When I felt bored with coping testcases , I decided to automate the Testopia update task and  that was my call .Many of my tester friends told me that they don't have any exposure to automation because management never told them to do any. According to me ,when to automate and what to automate  should come from tester and not from management. I usually see test managers  giving importance to the automation tools in a tester's skill set but according to me knowing when to automate is equally important as knowing the tools.

    Tuesday, June 8, 2010

    Selenium Webdriver running remotely

    Recently i started developing my automation code using Selenium2 code .Most of my code is for firefox driver .I need to confess that i liked Selenium2 really there are some stability issues in comparison to Selenium1 but it is good .

    Default usage of Selenium2 is that it will run server and client from same instance and that will control the browser elements,but Selenium2 provide a way to run server and client on remote location as you use to do in Selenium1.Remote Webdriver is the class which help you to run client and server separately .RemoteWebdriver provides a DriverServlet which if you add inside any servlet container you got your selenium server up.
    There are few examples for this in Selenium2 wiki site .As i have never ran servlet application before so i got in to little bit of issues following that .But finally i got it running and i used jetty as servlet container .Two ways you can include that in jetty

    1.Run jetty server on machine and put a war file on location pointed by jetty config file .
    2.Start jetty server from your application and add you servlet class to it .(I followed this method)

    I downloaded the selenium2 code and built remotewebdriver werver and client.
    command to built server
    ./go clean selenium-java selenium-server-standalone which will result in build/remote/server/server-standalone.jar
    command to built client
    ./go //remote/client:client:uber which will result in build/remote/client/client-standalone.jar
    *go is script comes with selenium2 code and code below i got it from wiki just made few changes .

    Server code
    AppServer.java
    =============================================
    import org.mortbay.jetty.Server;
    import org.mortbay.jetty.nio.SelectChannelConnector;
    import org.mortbay.jetty.webapp.WebAppContext;

    import java.io.File;

    import org.openqa.selenium.remote.server.DriverServlet;

    public class AppServer {

    public static void main(String s[]) throws Exception{
    Server server = new Server();


    WebAppContext context = new WebAppContext();
    context.setContextPath("");
    File st=new File(".");

    context.setWar(st.getPath());
    server.addHandler(context);

    context.addServlet(DriverServlet.class, "/wd/*");

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(3002);
    server.addConnector(connector);

    server.start();
    }
    }
    ================================
    Add server-standalone.jar ,jetty-6.1.9.jar and jetty-util-5.1.9.jar(you can download from jetty site or selenium2 code also has in third_party folder) to classpath and run above code.
    Your server will up with following message ---
    2010-06-08 11:07:00.730::INFO: Started SelectChannelConnector@0.0.0.0:3002

    Client example code
    FirefoxClient.java
    ================================
    import java.net.URL;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.WebDriver;

    public class FirefoxClient {

    public static void main(String s[]) throws Exception {

    URL url=new URL("http://127.0.0.1:3002/wd");
    DesiredCapabilities capabilities = new DesiredCapabilities();

    // ... but only if it supports javascript
    capabilities.setJavascriptEnabled(true);
    capabilities.setBrowserName("firefox");

    // Get a handle to the driver. This will throw an exception
    // if a matching driver cannot be located
    WebDriver driver = new RemoteWebDriver(url,capabilities);

    // Query the driver to find out more information
    //Capabilities actualCapabilities = ((RemoteWebDriver) driver).getCapabilities();

    // And now use it
    driver.get("http://www.google.com");
    }

    }
    =====================================
    Add client-standalone.jar to class path and run the above code .

    Friday, June 4, 2010

    motivation for Tester

    I was thinking what use to be the biggest motivation for me to deliver good quality of software i test .Is it appreciation from my manger or from my peers or from fellow developers when they appreciate about the how good the bug i reported.

    Yes these things motivate me too bu the thing which motivate me most is fixing of bug i reported .There how it goes whenever i file a bug(lets say critical) for any feature and if i try to find any other bug on that feature it is always difficult to find .Most of time i cannot go beyond my earlier bug i know it is not good for a tester but i guess it is psychological effect which does not allow me to see beyond .

    So keep me motivated i need my earlier bugs to be fixed and that is the biggest motivation for any tester .Once you get your bugs fixed you will be interested in testing more, to get more issues .