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

July 26, 2010

Table Partitioning - Basics

Today I want to revisit on SQL Server Table partitioning basics. To get started

Step 1 - Refresh the SQL Server Notes on Partitioning by Jose Barreto

Step 2 - Horizontal Vs Vertical Partitioning (Reference - Link)
Hortizontal Partition - Partition based on certain column value. Requires Partition Scheme, Partition Function and Partition Tables. Table will have all the columns
Vertical Partitioning - Divide table into multiple tables with fewer columns

Step 3 - Experiment Hortizontal Partitioning
a. Partition Function - A partition function specifies how the table or index is partitioned
b. Partition Scheme - Defines File groups mapping
c. Creating Partitioned Table

Creating a Partitioned Table for Class (Partitioned based on Class 1-12). When we query on a class only the particular partition is queried.
--STEP 1
IF EXISTS (SELECT * FROM sys.partition_functions WHERE name = 'TestPartitionFunction')
DROP PARTITION FUNCTION TestPartitionFunction;
GO
create partition function TestPartitionFunction (int) as range for values (1,2,3,4,5,6,7,8,9,10);

--STEP 2
IF EXISTS (SELECT * FROM sys.partition_schemes WHERE name = 'TestPartitionScheme')
DROP PARTITION SCHEME TestPartitionScheme;
GO
create partition scheme TestPartitionScheme as partition TestPartitionFunction all to ([PRIMARY]);
GO

--STEP 3
IF EXISTS (SELECT * FROM sys.tables
WHERE name = 'CLASSTable')
DROP TABLE CLASSTable;
GO

--STEP 4
create table dbo.CLASSTable (Class int, Name VARCHAR(200), Studentid int) on TestPartitionScheme (Class);
GO
CREATE CLUSTERED INDEX CIX ON CLASSTable(Class) ON TestPartitionScheme(Class)
GO

--STEP 5 Insert Data
declare @i int, @j int, @k int;
set @i=1;
set @j=100;
set @k = 1;
while (1=1)
begin;
INSERT INTO CLASSTable (Class, Name, Studentid)
VALUES (@i, Convert(VARCHAR(100),@j)+'Name',@j)
set @j=@j+1;
set @k = @k+1;
if(@k>100)
begin
set @k = 0;
set @j = @j+100;
set @i = @i+1;
end
if(@i>10)
begin
break;
end
end;
go

--Data in Each Partition
SELECT $PARTITION.TestPartitionFunction(class) AS Partition, COUNT(*) AS [COUNT]
FROM dbo.CLASSTable
GROUP BY $PARTITION.TestPartitionFunction(class)
ORDER BY Partition ;

--Data Searched only in required partition
SELECT *,$partition.TestPartitionFunction(Class) AS 'Partition Detail'
FROM CLASSTable WHERE Studentid=108

--Verify
set statistics profile on;
SELECT * FROM dbo.CLASSTable WHERE Studentid = 108 and Class = 1

Related Reads - Enabling Partition Level Locking in SQL Server 2008
Using Filtered Statistics with Partitioned Tables.
Partitioned Tables and Indexes in SQL Server 2005
Partitioning Summary: SQL Server 2005 vs SQL Server 2008


Happy Learning!!!

July 17, 2010

Alogorithm Problems

Alogorithm Problems
Question #1 - Given an array of N integers in which each element from 1 and N-1 occurs once and one occurs twice. Write an algorithm to find duplicate integer. Note- You may destroy the array.
Solution1:
Example Array is {1,2,4,7,8,9,4}
Use Negation to Identify the duplicate one. When you negate every element when you parse it would be like
{0,0,4,0,0,0}. Since 4 occurs more than once for the second time it would be 0-(-4). The resulting <> 0 number in the array is the duplicate occurence.
Note: Same logic can be used to count number of unique elements in an array.

Solution 2: Use XOR for solving this problem
Question#2 - Write a function to reverse a word in place O(n) time and O(1) space.
Solution:
void ReverseWord( char *t, int len)
{
  if(len<=1) return 1;
  Swap(&s[0],&s[len-1]);
  ReverseWord(s+1,len-2);
}

Question#3- Find Longest Sequence Palindrome in a String "abcabcad"
This is a Dynamic Programming problem.
Answer: Link1, Link2

Dynamic Programming
Good problems and answers
From the above link posting the solution
Let us define the maximum length palindrome for the substing x[i,...,j] as L(i,j)
Procedure compute-cost(L,x,i,j)

Input: Array L from procedure palindromic-subsequence; Sequence x[1,...,n] i and j are indices
Output: Cost of L[i,j]
if i = j:
    return L[i,j]
else if x[i] = x[j]:
    if i+1 < j-1:
        return L[i+1,j-1] + 2
    else:
         return 2
else:
return max(L[i+1,j],L[i,j-1])

Read Quote of Michal Danilák's answer to Dynamic Programming: Are there any good resources or tutorials for Dynamic Programming besides TopCoder tutorial? on Quora

More Reads
Are there any good resources or tutorials for Dynamic Programming besides TopCoder tutorial ?


Happy Learning!!!!

July 12, 2010

Web Driver

WebDriver (Built on top of selenium by google. UI Testing Framework)
Simple Example
1. Installed webdriver from link http://code.google.com/p/selenium/?redir=1
2. Extract and start eclipse plug-in. Create a Java Project and Add the Extracted JAR files in the project

3. Copied the code from Link - http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html. Modified the code to try it out in irctc.co.in
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestPoc1 {
/**
* @param args
*/
public static void main(String[] args)
{
    // TODO Auto-generated method stub
    // Create an instance of WebDriver backed by Firefox
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.irctc.co.in");
    driver.findElement(By.linkText(("Find Agents"))).click();
    WebElement searchBox = driver.findElement(By.name("pincode"));
    searchBox.sendKeys("560001");
    driver.findElement(By.name("Submit")).click();
}
}
4. Run this code as Java Application in elipse editor
5. References
http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html
http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions
http://code.google.com/p/selenium/w/list
http://blog.activelylazy.co.uk/2010/05/05/testing-asynchronous-applications-with-webdriver/
http://www.phpvs.net/2008/02/25/10-tips-for-building-selenium-integration-tests/
http://seleniumhq.org/docs/09_webdriver.html
http://www.theautomatedtester.co.uk/tutorials/selenium/xpath_exercise1.html
New Web Testing Tool -- WebDriver
What is Selenium WebDriver
Selenium Vs Webdriver
Getting Started with WebDriver (a Browser Automation Tool)
Good Reads
Tool #1 – WebDriver (Built on top of selenium by google. UI Testing Framework)

Tool#2 -fighting-layout-bugs a library for automatic detection of layout bugs in web page

July 10, 2010

Learning about website performance optimization

Yep. Very Interesting topic. I am learning by attending sessions and from my peers on website perf optimization. Couple of basic ideas

Basics Learning
How HTML, CSS and JS Work
  • HTML - Contains Text, body, paragraph
  • CSS - Font, Color, Size is defined in CSS
  • JS - Handling Events are defined in this file
Reference - How HTML, CSS and JS work together, CSS-Example
1. CDN (Content Delivery Network) - Delivering content based on Network Proximity. Duplicating data across multiple data centres. Downloads times would be reduced. More details CDN Link1, CDN Link2, CDN Link3
2. Image Spriting - Group Images together, Select Appropriate co-ordinates to display. One large image instead of several multiple small images. More Details Image Spriting1, CSS Sprites
3. Optimize the order of styles and scripts - I found this link extremenly good and self explanatory. Minimize round-trip times. "Browser delays rendering any content that follows a script tag until that script has been downloaded, parsed and executed".  By Adjusting the order download time can be minimized http://code.google.com/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts
4. Combine external JavaScript - Combine multiple files into optimal files. http://code.google.com/speed/page-speed/docs/rtt.html#CombineExternalJS
5. Several other useful techniques Enable Compression, Optimize Images, Caching are provided..
6. A better way to load CSS

More Reading - http://code.google.com/speed/page-speed/docs/rules_intro.html
Even Faster Web Sites Presentation 2 - High Performance Web Sites
Best Practices for Speeding Up Your Web Site
WebPageTest Demo
Waterfalls 101: How to understand your site’s performance via waterfall chart
Let's make the web faster
Page Test Tools: Which results should you trust?
Three kinds of page test visuals, and the best ways to use them
JavaScript Architecture
Unit Testing JavaScript with FireUnit
RequestReduce - Instantly make any ASP.NET website faster with almost no effort!

Tools
Top 10 Free Online Broken Link Checkers
Top 10 Tools to Test Website Speed
Top 10 Websites That Let You Check If Links Are Safe


Happy Reading!!!

July 01, 2010

Learning Selenium - Part II

In continuation to my earlier post. One of my friend asked me Pagination in Selenium. I got help from one of my team members Avinash.

Learning's are
1. Install Firebug add in to firefox
2. Install Xpather add in to firefox
3. From Existing post I want to goto page 2 of Search Results
4. Choose Xpather Location as shown below


5. Select the Xpath for Selecting Second page
6. Add the below line of code as last line. Only from footer part I am selecting the xpath.
selenium.click("//div[@id='foot']/table[@id='nav']/tbody/tr/td[3]/a/span[1]");
7. Modified code snapshot as below


7. Search Results would take you to page 2 of results
Good Read - Identifying XPath of a element using XPath Query
Happy Reading!!!