"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 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!!

No comments: