"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

August 22, 2010

Technology Vs Architecture Vs Supportability Vs Business Requirements

Multiple Development Models - Waterfall, SCRUM, Kanban, Pair Programming, XP. We have different functions Dev, Test, Support, Program Management, Architects, Business....Priorities and goals of all the functions differ..

Perspectives - Design A for Problem P has two options. 40 Hrs in one Approach, 100 Hrs in another Approach. Architects approve for Approach 100hrs as it provides a reusable framework/scaleable.....40Hrs solution does meets the needs of the business and keeps the business running

Objective of Test is Zero Bugs in Production. I have never seen any critical releases without bugs. I am not advocating for bugs. When you develop a large system, certain edge cases could have been missed. Acquiring expertise in Domain/Application needs Interest/Passion. Test transforming from mere testers to Functional Experts needs lot of homework, reading  competitors approach, business value realized in every new feature/CR added to the application. From being takers to questioning the impact / value of a change is very important....

Technology changes its pace every year..Developing an Application in a Beta Platform Vs Developing in a stabilized platform has its own pros and cons. Objective is to deliver value. This is the first priority and top priority.

We do not have a system which gets requirements as input and produces code as output.

Working together for making a release is different from working to prove one function is better than another function. You work with very skilled-efficient-geeks. Learn all the good things and take it with yourself. All other -ve items garbage collected.

Get into as much detail as possible right from BRD(Use Cases, Functionality, In Scope, Out of Scope). Functional Spec - Cover high level aspects and all possible cases and expected behavior from the system. Design for Scalability, Performance, Usability. Every time we learn in every release.. Continuous Learning from past mistakes and encouragement from past achievements would help us delivering our best.

August 21, 2010

Learning TestNG & Selenium

TestNG is a testing framework
  • Developed by Cedric Beust
  • Provides support for Data Driven Testing
  • Provides annotations for Pre-Test, Assigning Data, Executing Test, Verifying results (Assert)
Annotation - Way of associating metadata (declarative information) with program elements such as classes, methods, fields, parameters, local variables, and packages.

How Annotation works - Annotations hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then. Reference
Get TestNG Eclipse plug-in - This allows you to run your TestNG tests from Eclipse and easily monitor their execution and their output.

Basic Example
1. Create a basic java project in eclipse editor
2. Add TestNG jar in Libraries. You can download it from testng.org
3. Create example1.java and paste the below code
----------------------------------------------------------------------------------------------------------------------------------
import java.util.Vector;
import org.testng.Assert;
import org.testng.annotations.*;
public class example1 {
private int a;
private int b;
private int c = 0;

@BeforeClass
public void setUp() {
// code that will be invoked when this test is instantiated
}
//This method will provide data to any test method that declares that its Data Provider is named "test1"
@DataProvider(name = "test1")
public Object[][] createData1()
{ return new Object[][]
{ { new Integer(40), new Integer(30)}
};
}
//This test method declares that its data should be supplied by the Data Provider named "test1"
@Test(dataProvider = "test1")
public void verifyData1(Integer a, Integer b)
{
c = a + b;
Assert.assertEquals(c, 70);
System.out.println("Fast test");
}
@Test(groups = { "slow" })
public void aSlowTest() {
System.out.println("Slow test");
}
}
----------------------------------------------------------------------------------------------------------------------------------
4. Run this as a TestNg Test
5. Result would be
Slow test
Fast test
PASSED: aSlowTest
PASSED: verifyData1(40, 30)
A test is successful if no exceptions are thrown.

More Reads
Basic Example
TestNG Documentation on exposed methods
Junit Vs TestNG

Moving to Next Level - Integrating Selenium and TestNG
1. Start the Selenium Server thru command mode by command java -jar selenium-server.jar. Open Command Windows in Administrator Mode (For Win7)
2. Create a java Project. Add TestNG Library and Selenium Java Client Driver Jar files
3. Paste the below code
----------------------------------------------------------------------------------------------------------------------------------
import static org.testng.Assert.assertTrue;
import java.util.Vector;
import org.testng.Assert;
import org.testng.annotations.*;
import com.thoughtworks.selenium.*;
public class example1 {
public static Selenium selenium;
@BeforeTest
public void openBrowser() {
System.out.println("Before Test");
selenium = new DefaultSelenium("localhost", 4444, "*iehta",http://google.com/);
}

@AfterTest
public void closeBrowser() {
System.out.println("After Test");
selenium.stop();
}

@Test
public void Testmethod() {
System.out.println("Running Test");
selenium.start();
selenium.open("http://google.com");
selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.setTimeout("1000000");
assertTrue(selenium.isTextPresent("seleniumhq.org"));
}
}
----------------------------------------------------------------------------------------------------------------------------------
4. Run as TestNG Test
5. Result would be
Before Test
Running Test
After Test
PASSED: Testmethod

Next Example
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.testng.Assert;
import org.testng.annotations.*;
import static org.testng.Assert.*;
public class test {

@DataProvider(name = "test1")
public Object[][] createData() {
    Object[][] retkeyword={{"One"},
                        {"Two"},
                        {"Three"}};
    return(retkeyword);
}

//This test method declares that its data should be supplied by the Data Provider named "test1"
@Test(dataProvider = "test1")
public void verifyData1(String keyword)
{
      System.out.println("Value :"+keyword);
}
}

Example - III
I am updating it with complete steps as some of the links seems to be invalid now. This is extension of previous post

1. Install JDK 6 or any latest version

2. Download Eclipse IDE for Java Developers


3. Unzip and Run Eclipse.exe as shown below

4. Download Testng jar file for project.

5. Create a new project and add the external jar as shown below

6. Copy-paste below source code in java file created for the project


import org.testng.annotations.*;
            import org.testng.*;
public class FirstExample {
    private int a;
    private int b;
    private int c = 0;
    @BeforeClass
    public void setUp() {
        // code that will be invoked when this test is instantiated
    }

    //Data Provider provide input test data (2 Integer Numbers)
    @DataProvider(name = "Add2Numbers")
    public Object[][] createData1()
    { return new Object[][]
    { { new Integer(2), new Integer(2)},
            { new Integer(3), new Integer(3)},
            { new Integer(4), new Integer(4)}
        };
    }

    //Test method gets input from data provider Add2Numbers
    @Test(dataProvider = "Add2Numbers")
    public void testtoAddnumber(Integer a, Integer b)
    {
        c = a + b;
        verify(c,a,b);
    }   

    public void verify(Integer c, Integer a, Integer b)
    {
        Assert.assertEquals((Integer)(a+b), (Integer)c);
        System.out.println("Test Completed");
    }  

} 

7. Eclipse IDE, Under Help-Install Software Install TestNG-Add on as shown below. First Provide the URL, then Add it with Name.



8. To Run the test please find below snapshot

9. Output from console window



10. Explanation for Annotations
@Dataprovider – Here is where we can read from xml / write custom code for setting test data. The return type is an object. Depending on number of objects returned test would run that many times.
@Test – This is the test which we would run, We have mentioned the data provider for that particular test. Return Type of Data provider is the input parameter for the test method. You can provide type of test (Functional / regression / priority)
You also have other annotations like pretest, posttest, onsuccess, onfailure, run parallel tests


Happy reading!!

August 19, 2010

Data Driven Testing and Design patterns

Model Based Testing - Model is translated to or interpreted as a finite state automaton or a state transition system. This automaton represents the possible configurations of the system under test. Link

Data Driven Testing
  • Test the system with wide set of Data
  • Is a Part of Model Based Testing
  • Validate boundary conditions and invalid input
Keyword Driven Testing - keyword-driven test is a sequence of operations, in a keyword format, that simulate user actions on the tested application. Entire Functionality gets captured as step by step. Now I have a Question. What is difference between Model based testing & Keyword driven testing.

From my experience suppose we simulate a Railway Ticket booking, If we call the required APIs Validate Customer->Find Trains->Book Ticket. If I simulate this workflow It appears to me like a model based test case. If I login in UI and do a record & play back using selenium/third party tools this would capture the events and data. This appears like keyword driven testing. Its my understanding. Feel free to write you comments or correct me if I am missing anything.

Design pattern - Detailed, reusable, tried, and tested solution for a recurring problem

Factory Method
Precise Summary of Factory pattern
  • Define an interface for creating an object, but let the subclasses decide which class to instantiate
  • The Factory Method lets a class defer instantiation to subclasses
Example Code
interface IClientproperty
{
      public String SetRegion();
}

class clientpropertyAPAC implements IClientproperty
{
      public String SetRegion()
      {
            return "Region Value is APAC";
      }
}

class clientpropertyUS implements IClientproperty
{
      public String SetRegion()
      {
            return "Region Value is US";
      }
}

class clientpropertyEMEA implements IClientproperty
{
      public String SetRegion()
      {
            return "Region Value is EMEA";
      }
}


public class FactoryPattern
{
      public static void main(String args[])
      {
                  FactoryPattern program = new FactoryPattern();
                  IClientproperty objBase = program.GetObject("US");

                  FactoryPattern program2 = new FactoryPattern();
                  IClientproperty objBase2 = program2.GetObject("APAC");
                 
                  FactoryPattern program3 = new FactoryPattern();
                  IClientproperty objBase3 = program2.GetObject("EMEA");

                  System.out.println("Results\n");
                  System.out.println("Result One is :"+ objBase.SetRegion());
                  System.out.println("\nResult Two is :"+ objBase2.SetRegion());
                  System.out.println("\nResult Three is :"+ objBase3.SetRegion());
     
      }
     
      public IClientproperty GetObject(String Region)
      {
           
            IClientproperty objBase = null;
           
            if(Region.equals("US"))
            {
                  objBase = new clientpropertyUS();
            }
            else if(Region.equals("APAC"))
            {
                  objBase = new clientpropertyAPAC();
            }
            else if(Region.equals("EMEA"))
            {
                  objBase = new clientpropertyEMEA();
            }
            return objBase;
      }
     
}
Output
Results

Result One is :Region Value is US

Result Two is :Region Value is APAC

Result Three is :Region Value is EMEA


Abstract Factory Pattern

  • Define an interface for creating an object,but let subclasses decide which class to instantiate. Factory method lets a class instantiation to subclasses.
  • Provide an interface for creating families of related or dependent objects without specifying their concrete classes
  • Example and usage listed in Link
Singleton Pattern - Ensure a class has only one instance, and provide a global point of access to it. Example link
Singleton Pattern
Builder Pattern
Random linked list
More reads.. @ Link
C# Design Pattern–Singleton
C# Design Pattern–Proxy
C# Design Pattern–Factory Method


Good Read
Happy Reading!!

August 14, 2010

Evaluating a Test Case Management Tool (TCM)

I am currently learning SpiraTest tool. A good Test Case management Tool would address the below items

1. Easy of use for writing test cases
2. Record Test Execution and Results
3. Maintenance and Updating Regression test cases
4. Usability (Tree type view, Easily update & modify test cases)

Adding Test Cases in Spira Test
  • Web based - This is slightly slow.
  • Excel based Import of Test Cases - Seems to be a promising feature. Writing Test Cases in Excel and Importing it to SpiraTest works well. I like this Feature.
Managing Regression Test Cases
  • Modifying adding and deleting Regression Test Cases - You have good option in web UI to manage test case, copy and move them across release folders
Tracking Test Execution and Reporting
  • Tracking Test Execution and Reporting Test Execution Summary, Monitoring Progress
I still need to learn and update on Reporting..Will do it soon..

Please find summary of my analysis on TCM tools..
More Reads
Good ReadTop 10 Open Source Bug Tracking System
Compiled - Testing and TCM tools list - Good One
Tools Battle: SpiraTest, TestRail and TestLodge
Open Source Test Management Software


Happy Reading!!