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

December 27, 2010

Ringo - Selenium Automation Framework by Google

I found below link useful for developing automation framework using selenium.



tseng -  based on Google's Ringo now available for public. Link
Presentation slides available in link
Notes from the talk
Design Decisions
  • Build common framework
  • Isolate Test Case specific details
  • Application specific logic kept in client class
  • Provide uniform way of accessing UI elements
  • Flexibility - Group Test Cases
  • Placeholder for configuration data
  • Maintainability - Maintaining Data for Testcases
  • Support Data Driven Test, Same test run with different sets of data
Architecture
  • Tool Selection Criteria - Handle AJAX Controls
  • Selenium Locators - Identify element in page
  • Testing Framework - TestNG
  • Data provider features- Support for Data Driven Testing
  • TestNG would handle looping and invoking methods
  • Read from XML, Database is supported
  • Firebug - Used as Development Tool
Architecture
  • Configuration Layer
  • UI Layer Abstraction
  • Application logic lies in client class
  • Uniform way of accessing UI object using helpers
  • UI Map - Storing UI Elements
  • Data could be shared acrosss Test Cases
  • Keep data in one place
  • Web Apps Common Action - Filling forms
  • Helper class takes page & data object
  • For each UI element fill corresponding provided values
  • Changes is updating UI & Datamap
  • Application Client - Subtree of classes
Application Test
  • Contains Test cases, Uses API's provided by client class
  • Test Case Flow - Test Case -> Client Class (High level API) -> Helper (Common actions, Wrapper classes using selenium commands)
Yep, Excellent Presentation and lot of Information for building automation framework.

More Reads - Link1, Link2
Selenium - is NOT a Framework
Template method pattern
Selenium 2 Examples
Web test automation best practices
First steps with Lightweight Test Automation Framework
Selenium Framework by Google

December 21, 2010

TestNG: Passing Array of Objects in DataProvider


Now in this example, We will try an example to pass Array of Objects in the Dataprovider for TestNG test.

Please find working code and example listed below. Please run it as TestNG test in your eclipse editor


import java.util.ArrayList;
import java.util.HashMap;
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.*;
import java.util.*;

//Example for Array of Objects
public class TestNGExample
{

 private String InputData;
 private List<String> ExpectedResults = new ArrayList<String>();
public String getInputData()
{
  return InputData;
}

public void setInputData(String inputData)
{
  InputData = inputData;
}

public List<String> getExpectedResults()
{
  return ExpectedResults;
}

public void setExpectedResults(List<String> expectedResults)
{
  ExpectedResults = expectedResults;
}


@DataProvider(name = "Array of objects Example")
public Object[][] parameterIntTestProvider()
{
  System.out.println("Start Data Provider Section");
  List<String> TestOneExpectedList = new ArrayList<String>();
  TestOneExpectedList.add("one expected");
  TestOneExpectedList.add("Three expected");
  TestOneExpectedList.add("two expected");
  TestOneExpectedList.add("four expected");

  List<String> TestTwoExpectedList = new ArrayList<String>();
  TestTwoExpectedList.add("one expected");
  TestTwoExpectedList.add("Three expected");
  TestTwoExpectedList.add("two expected");
  TestTwoExpectedList.add("four expected");

  TestNGExample[] Arrayobj = new TestNGExample[2];
  System.out.println("Declaration Successful : Assign Data Provider");
  Arrayobj[0] = new TestNGExample(); // I made mistake here, Commenting to highlight learning
  Arrayobj[0].setInputData("One");
  Arrayobj[0].setExpectedResults(TestOneExpectedList);
  System.out.println("First Assignment : " + Arrayobj[0].getInputData());

  Arrayobj[1] = new TestNGExample();
  Arrayobj[1].setInputData("Two");
  Arrayobj[1].setExpectedResults(TestTwoExpectedList);
  System.out.println("End : Assign Data Provider");

  for (int i = 0; i < 2; i++)
  {
   TestNGExample arrayobj = Arrayobj[i];
   System.out.println("Input Data is :" + arrayobj.getInputData());
   List<String> ls = arrayobj.getExpectedResults();
   Iterator it = ls.iterator();
   while (it.hasNext())
   {
    String value = (String) it.next();
    System.out.println("Value :" + value);
   }
  }
 return new Object[][] { { Arrayobj } };
}

@Test(dataProvider = "Array of objects Example")
public void TestMethodforClass(TestNGExample[] Arrayobj)
{
  System.out.println("Start Test : Array of objects Example");
  for (int i = 0; i < 2; i++)
  {
    TestNGExample arrayobj = Arrayobj[i];
    System.out.println("Input Data is :" + arrayobj.getInputData());
    List<String> ls = arrayobj.getExpectedResults();
    Iterator it = ls.iterator();
    while (it.hasNext())
    {
     String value = (String) it.next();
     System.out.println("Value :" + value);
    }
   }
  System.out.println("End Test : Array of objects Example");
 }

}

Results
Start Data Provider Section
Declaration Successful : Assign Data Provider
First Assignment : One
End : Assign Data Provider
Input Data is :One
Value :one expected
Value :Three expected
Value :two expected
Value :four expected
Input Data is :Two
Value :one expected
Value :Three expected
Value :two expected
Value :four expected
Start Test : Array of objects Example
Input Data is :One
Value :one expected
Value :Three expected
Value :two expected
Value :four expected
Input Data is :Two
Value :one expected
Value :Three expected
Value :two expected
Value :four expected
End Test : Array of objects Example
PASSED: TestMethodforClass([LTestNGExample;@1ac2f9c)


Below link was useful for working on Array of Objects.

Happy Reading!!

December 19, 2010

TestNG - Assigning Data Providers using Class Members

In continuation with previous posts, We will look at passing data using class members. The following blog helped me to understand and write the example

Please find working code and example listed below. Please run it as TestNG test in your eclipse editor

import java.util.ArrayList;
import java.util.HashMap;
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.*;
import java.util.*;

public class Test3
{
 private String InputData;
 private String ExpectedResult;
 private List<String> ls = new ArrayList<String>();

 public List<String> getLs()
{
  return ls;
 }
 public void setLs(List<String> ls)
{
  this.ls = ls;
 }
 // Under Source Menu Select Generate Getters & Setters - Tip from my colleague Avinash
public String getInputData()
{
  return InputData;
 }

 public void setInputData(String inputData)
{
  InputData = inputData;
 }

 public String getExpectedResult()
{
  return ExpectedResult;
 }

 public void setExpectedResult(String expectedResult)
{
  ExpectedResult = expectedResult;
 }

@DataProvider(name = "Dataprovider set with class members")
public Object[][] parameterIntTestProvider()
{
  Test3 obj = new Test3();
  obj.setInputData("TestInput");
  obj.setExpectedResult("TestExpectedResult");
  List<String> TestList = new ArrayList<String>();
  TestList.add("one expected");
  TestList.add("Three expected");
  TestList.add("two expected");
  TestList.add("four expected");
  obj.setLs(TestList);
  return new Object[][] { { obj } };
 }

@Test(dataProvider = "Dataprovider set with class members")
public void TestMethodforClass(Test3 TestClass)
{
  System.out.println("Start Test : Dataprovider set with class members");
  System.out.println("Input Data is :" + TestClass.getInputData());
  System.out.println("Expected Result is :"+ TestClass.getExpectedResult());
  List<String> ls = TestClass.getLs();
  Iterator it = ls.iterator();

  while (it.hasNext())
{
   String value = (String) it.next();
   System.out.println("Value :" + value);
  }
  System.out.println("End Test");
 }
}

Hope it Helps!!

Selenium Automation Tricks From Selenium Wiki

Bunch of useful posts I bookmarked for Selenium. A very good site Selenium Wiki, UnLtdGroup| Selenium Wiki I came across. Nice work by Pavandeep managing the site. Impressive quote "It is not the software that is great; it's the people who use it who make it great". Sharing the Learning's very much appreciated.

Useful posts I bookmarked for my future reference
Commonly Used Selenium Commands
Selenium Data Driven Testing with C#
Selenium RC with Java and JUnit
Selenium – verifyXpathCount
Using Xpath in Selenium and Selenim RC
Using Selenium IsVisible
Using Array to execute Selenium commands in C#
How to verify the image height and width in Selenium
Getting the Browser details in Selenium
Selenium and Hudson Integration:Keeping your Test Code separate from execution code
Selenium Tutorial: Ant Build for Selenium Java project
Handling JS Errors in Selenium
Handling Pop-up Windows in Selenium
Upload a File in Selenium
Java Properties File
Measuring Web Page Performance with Selenium 2 and the Web Timings API
Selenium 2 - Get Number of Rows in a Table


Next set of links
Automated Selenium Testing with Maven
Maven Selenium
Defining test descriptions in testng reports
Extending Selenium server with custom commands
Maven Getting Started Guide
Using groups with TestNG
Start your webtests with Selenium2, Maven, TestNG – now
Next-Generation Testing with TestNG
TestNG - Basic
TestNG Report
ReportNG
How To Get Started With Selenium Core And ASP.NET MVC
Selenium IE Issues
Writing Selenium Tests
Using XPath Expressions as Locators
Selenium XPath Cheatsheet
Selenium Locator Tips

Java Script Error Handling
Checking for JavaScript Errors with Selenium

Selenium Xpath Reads
Selenium Xpath
Selenium Locators
Selenium Tips: Start improving your locators
How To Minimize The Pain Of Locator Breakage
Selenium Tips: CSS Selectors in Selenium Demystified

Happy Reading!!

TestNG - Passing List & Hash as Single parameter

In continuation with my previous post, Now I tried for Passing List & Hash as Single parameter. Below is the example code

Below is the working example code

import java.util.ArrayList;
import java.util.HashMap;
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.*;
import java.util.*;
public class Test1 {
@DataProvider(name = "Passing Three Parameters")
 public Object[][] createDataforTest1()
{
  System.out.println("Start Data Provider: Test1");
  Map<String, String> TestData1 = new HashMap<String, String>();
  TestData1.put("Onee", "One");
  TestData1.put("Twoo", "Two");
  Map<String, String> TestData2 = new HashMap<String, String>();
  TestData2.put("One", "One Expected");
  TestData2.put("Two", "Two Expected");
  Object[][] retkeyword = { { "One", TestData1, TestData2 },
    { "Two", TestData1, TestData2 } };
  System.out.println("End Data Provider: Test1");
  return (retkeyword);
 }
@DataProvider(name = "Passing List & Hash as Single parameter")
public Object[][] createDataforTest2()
{
  System.out.println("Start Data Provider: Test2");
  HashMap<String, List<String>> TestData3 = new HashMap<String, List<String>>();
  List<String> ls = new ArrayList<String>();
  ls.add("one expected");
  ls.add("Three expected");
  ls.add("two expected");
  ls.add("four expected");
  TestData3.put("One", ls);
  TestData3.put("Two", ls);
  Object[][] retkeyword = { { "One", TestData3 }, { "Two", TestData3 } };
  System.out.println("End Data Provider: Test2");
  return (retkeyword);
 }
 @Test(dataProvider = "Passing List & Hash as Single parameter")
 public void verifyData3(String keyword,HashMap<String, ArrayList<String>> hm)
{
  System.out.println("Start Test : Passing List & Hash as Single parameters");
  System.out.println("Keyword :" + keyword);

  List<String> ls = hm.get(keyword);
  Iterator it = ls.iterator();
while (it.hasNext())
{
   String value = (String) it.next();
   System.out.println("Value :" + value);
  }
  System.out.println("Keyword present in List " + ls.contains(keyword));
  System.out.println("End Test");
 }
@Test(dataProvider = "Passing Three Parameters")
public void verifyData3(String keyword, HashMap hM1, HashMap hM2)
{
  System.out.println("Start Test : Passing Three Parameters");
  System.out.println("Keyword :" + keyword);
  System.out.println("HashMap 1 Value is :" + hM1.get(keyword)
    + " Second HashMap value is :" + hM2.get(keyword));
  System.out.println("End Test");
 }
}
Hope it Helps!!

December 18, 2010

TestNG - Passing Multiple parameters in DataProviders

I am learning TestNG. This blogpost is for passing multiple parameters for Test method using data providers. To get started with TestNG please refer link.

Below is code snippet I tried. This is working code.

Dataproviders in TestNG test

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.*;
import java.util.*;
public class test {
@DataProvider(name = "Pass Single Parameter")
public Object[][] createData() {

    Object[][] retkeyword={{"One"},
                        {"Two"},
                        {"Three"}};
    return(retkeyword);
}

@DataProvider(name = "Passing Two parameters")
public Object[][] createDataforTest2() {
 List<String> ls=new ArrayList<String>();
 ls.add("one expected");
    ls.add("Three expected");
    ls.add("two expected");
    ls.add("four expected");
    Object[][] retkeyword={{"One", ls},
                        {"Two", ls},
                        {"Three", ls}};
    return(retkeyword);
}

@DataProvider(name = "Passing Three parameters")
public Object[][] createDataforTest3() {
    HashMap hm = new HashMap();
    hm.put("One", "One Test");
    hm.put("Two", "Two Test");
    hm.put("Three", "Three Test");

 List<String> ls=new ArrayList<String>();
 ls.add("one expected");
    ls.add("Three expected");
    ls.add("two expected");
    ls.add("four expected");
    Object[][] retkeyword={{"One", ls, hm},
                        {"Two", ls, hm},
                        {"Three", ls, hm}};
    return(retkeyword);
}

@Test(dataProvider = "Passing Three parameters")
public void verifyData3(String keyword, ArrayList<String> ls, HashMap hm)
{
   System.out.println("Passing 3 parameters to Test");
   System.out.println("Start Test");
   System.out.println("Value :"+keyword);
      Iterator it=ls.iterator();
      while(it.hasNext())
      {
        String value=(String)it.next();
        System.out.println("Value :"+value +" Hash Map is "+ hm.get(keyword));
      }
      System.out.println("End Test");
}

@Test(dataProvider = "Pass Single Parameter")
public void verifyData1(String keyword)
{
   System.out.println("Passing Single parameter to Test");
   System.out.println("Start Test");
      System.out.println("Value :"+keyword);
      System.out.println("End Test");
}

@Test(dataProvider = "Passing Two parameters")
public void verifyData2(String keyword, ArrayList<String> ls )
{
   System.out.println("Passing Two parameter to Test");
   System.out.println("Start Test");
      System.out.println("Value :"+keyword);
      Iterator it=ls.iterator();
      while(it.hasNext())
      {
        String value=(String)it.next();
        System.out.println("Value :"+value);
      }
      System.out.println("End Test");
}
}

Hope it helps!!

December 13, 2010

Visibility aspect @ Work

I have seen instances where being visible helped people grow but I personally don’t believe in ‘Being centre of Attraction or Acting smart in front of senior management’ is a way to promote you.

People must be evaluated based on their achievements not based on their visibility. But sometimes it’s the other way. Skills will help you work anywhere. Visibility helps you sustain your current role.

Visibility by itself is a talent. Ability to convince and create perception is a talent. It’s the responsibility of the manager to differentiate visibility vs ability. People who contribute to the organization are as important as people who represent the organization. End of you day you need to be satisfied with your work. This alone can give you satisfaction.

”A good conscience is a soft pillow”.....

December 10, 2010

Process Failures - Reality Check

For every role, job profile - Dev, Test, Support there would be areas of improvements / continuous improvements / Removing Muda (Waste) / Kaizen ....

From Customer perspective - Looking for working product @ the earliest time
From IT Project Team perspective - Meet the Requirement, Beat the Schedule, Manage the Cost
From Development Perspective - Functionality agreed and Signed off to Freeze Design
From Test Perspective - Access functionality changes in every iteration and test it

Where is the Noise
  • Everything looks fine with the first draft version of functional spec.During Design when it changes this has ripple effect in design, testing, schedule and timeline.
  • Not Every Business Team is IT Savvy. Not every IT team understands the project business value
  • Communication does to flow across the team consistently. Keeping whole in same page requires effective communication
What Actually Happens
  • Developer spending late nights @ work to make code release
  • Test Team testing during weekends/working beyond office hours to meet the schedule  
  • Work + Work - Life, Work Life Balance Issues
Reality of Process Implementation
  • Process is a guideline not the best practice, Getting better at things we do helps us improve ourselves and Improve working environment
  • I really doubt every developer aware of best coding practice / Every tester aware of best testing practices
  • I have a team of 10 Developers. How do we ensure everyone develops the same quality of code
  • Enforce-Use tools to implement Code Checks - This is a reactive way in my perspective
  • If I know this is the best practice to handle this problem. Memory use, Better Logic. Make everyone understand rationale behind usage of particular approach.
  • Knowing facts is not sufficient. You also need to know Why?
  • Have this best practices shared in Email Communications, Employee Kits, Notes, Posters
  • Subscribe to a newsletter for a subject and learn it thoroughly
  • Best practices once developed never get communicated (marketing) - selling part of it is often poor. A best practice should justify why it is a best practice, how it evolved, Future reading....
  • Knowledge Sharing Sessions - Reading Subject matter experts blog - Blogging your learnings are good ways of learning and sharing....
Sometimes it is worth to re-learn!!

Happy Reading!!

TestNG Automation Tricks

Very Good and useful links on TestNG based data-driven Automation. Please check on earlier posts labelled selenium to get started with Selenium and TestNG.

Stupid TestNG Tricks - Reading Input from File
Parallel Testing with TestNG DataProviders
DataProvider for Object as Parameter
Using TestNG to launch your tests (and the Selenium server)
TestNG GTAC Presentation
Setting up a test project with Selenium, TestNG and Maven
Difference between Junit and TestNG
Everytime when you know more about something you already know. It only means you ( I ) have to learn better....

Happy Reading!!

December 04, 2010

Web Service Testing

Yes, Learning basics once again. Basics of Web Services, How it Works. Testing has been fairly easy using Web Service Studio Tool.
Web Service - What is it
  • Web Services is all about XML
  • Enables this communication by using open protocols and standards XML, SOAP and WSDL
  • Structure of the messages is described using XML Schema (XSD)
Why Web Services
  • Platform-independent - The use of open protocols enables Web services to be platform independent
  • Secure - Enable SSL, Certificates
Technology
  • WSDL (Web Services Description Language) - WSDL is a document that describes a Web service and also tells you how to access and use its methods.
  • UDDI - Universal Description, Discovery and Integration - Organizations register their Web services in a global directory so clients can find them
  • SOAP - Simple Object Access Protocol. Messaging protocol. SOAP is a simple XML-based protocol to let applications exchange information over HTTP.
How it works
A very good walkthrough is provided in link. Client sends Serialized SOAP Request. This is Deserialized by the Server. The response is again Serialized and passed to the client in SOAP Response in serialized format. Deserialization happens at Client again.

Performance 
Typically there would be multiple consumers who can consume this service, scalability and performance is very important for web service

Web Services Testing
Fairly Simple. Provide the wsdl URL in Web Service Studio Tool. Methods would be listed. Easy Walkthrough and tool download in link
Web service Studio 2.0 by Sowmy Srinivasan - Link
More Tools Read
More Reads

Happy Learning!!!

November 27, 2010

How Website testing is different from Database testing

How Website Testing is different from Database Testing
Website testingDatabase testing
Event Driven - Actions Depend on Options Choosen by the UserData Driven, Fixed Set of Steps Executed by a Procedure
Website Testing is Black Box Testing, Focus is on end-to-end FunctionalityDatabase Testing is more driven towards white box Testing, Need to verify TSQL Code, Logic, Datatypes, Constraints at Table Level, Refer Database Testing
Page Load time is very critical for better user experienceFor OLTP Applications Ex-online ticket booking procedures need to be optimal to ensure maximum level of concurrency
Performance Points - User Response Time, Response Time with Concurrent UsersPerformance Points - Blocking, Locking, Deadlocking during Performance Testing. Detailed notes are provided in blog for each of the listed items
Black Box Testing PredominantlyIt is possible to trasition from a DB tester to DB Developer Since you work the code, You understand the code/logic
Checking SQL Jobs, Database Migrations Ex- SQL 2000 to SQL 2005, SQL 2005 to SQL 2008
OLTP Vs OLAP Systems. Both are very different and has its own learning. I have mainly worked on OLTP

Website would multi-tier app. Client-Business Layer-Database Layer. Database would also be covered at certain point.

Happy Reading!!

Best Practices for Website Testing

For Testing a website below are guidelines I found useful from my learning's till date

1. Functionality Testing - Verify the features/functionality of the site
2. Acceptance Testing - This is event driven, User can interact the site in several different ways. It is very important to cover maximum user scenarios to ensure no defects at integration layer
3. Localization Testing - Check the website if it is available in several languages. Useful tip - Google Chrome suggests translation to english when you open Non-English Locale Sites. You can use this to read/understand by translating the content to English.
4. Layout Testing - Verify the look and feel of the UI. No overlapping sections in the page. Refer the Tool
Layout detection tool, Layout Detection Tool Intro Video
5. Cross Browser Testing - Verify the UI of the website in multiple browsers. Useful Read Top 10 Free Web Apps to Test Cross-Browser Compatibility
6. Cross Platform Testing - Testing across browsers in different platforms Windows/Linux/Mac. Good Read Useful Tools for Testing Cross Browser Compatibility
7. Broken Links - Verifying Links in the page are not broken - Useful Tools. Tool1, Tool2
8. Spell Check the contents of the page. Good Read Top 10 Free Online Spell Checkers
9. Verify the page load time across different browsers. Good Read Top 10 Tools to Test Website Speed
10. Security Testing - Verify Security of the website is not broken or can be compromised with special attacks. Check for XSS. Tools to check  both at code level/site level are available. 10+ Free Web Application Security Testing Tools
11. Slow Network Traffic - Check for the Page Load time, Look and Feel in Case of Slow Network Traffic. Useful Tool BrowserMob Proxy - Free Tool to simulate slow network traffic
12. Usability Testing - How much does it Actually meets End User Requirements. Is it user friendly. Usability Testing Guidelines
13. Web Test Automation - For Website Test Automation you can check Open Source Tools Selenium, Webdriver
14. More Reads - Guidelines and Checklist for Website Testing
15. Open Source Test Automation Framework Using Selenium. This underlying framework can be leveraged and developed to support automation for existing website - Tracking Selenium Commands Using C# and SQL Server 2008. Framework Code Available in Selenium Tracking
16. Very Good Ebook on Selenium for Web Test Automation. Link
17. 7 useful tools for web development testing
18. Selenium Online Training
19. Next thing to look is Automating Regression & Functional Test Cases. You can automate functional test cases based on priority. Based on production defects / changing features this can be updated
20. Capture production events of customer acitivty on the website. Top 10 worflows can serve as input to performance test scenarios. Based on distribution of it, performance test scenarios can be developed from it to simulate production work load.
21. Twenty essential firefox addons for testing
22. Traffic Squeezer - Open-Source WAN/Network Optimization and Acceleration Solution
23. Few tips for quality web page testing
24. Cross browser testing – The truth is in the numbers


Happy Reading!!

November 17, 2010

Installing Turbo C++ in Win7 64 bit

I spent good amount of time looking for a Free IDE for trying out C/C++ programs. Below link
How to install Turbo C++ on Windows 7 64bit explains setup step by step

Few things I found useful to be added are
1. After mounting to D Drive, You need to run install.exe under dosbox to get all files unzipped
2. I downloaded DOSBox 0.74 version. The config file is located in
{system drive}:\Users\{username}\AppData\Local\DOSBox\dosbox-{version}.conf
3. Added the below content
mount d c:\turboc
d:
cd tc
cd bin
tc

Now on click of DOSBox shortcut C++ IDE is ready!!
Time to learn/code some more Programming Problems.....

Found yet another simple solution. Use http://codepad.org/ :) :)

Happy Coding!!

November 16, 2010

Software Testing - Learning Articles - Posts - Compiled

Below is summary of Software testing related posts in my blog till date plus interesting testing related article bookmarks
  1. Guidelines for Web Site Testing
  2. Database Testing Overview
  3. Performance Testing Overview
  4. Web Service Testing
  5. Test Estimates
  6. Testing best Practices
  7. Value Realization of Test Function
  8. Web Services Testing, Testing Tool for webservice testing
  9. UI Test Automation using Selenium
  10. Test Automation - Regression Test Automation Myths, Software Testing Interesting Reads - Sara Ford
  11. Test Case Management Tools Analysis
  12. Test Automation patterns
  13. Test Automation Tools - Good Summary
  14. Functional Testing Tools List
  15. Test Heuristics Cheat Sheet
  16. Tester 2.0 - Definition of an Agile Tester
  17. Manual Testing Notes
  18. Testing Mobile Apps
  19. Google Testing Blog good read - Approach on Categorizing test sizes - Good Read
  20. Google Testing Blog good read - Web Testing at Google
  21. Using Mind Maps for Test Planning
  22. An effective test strategy to grow applications - Good Read
  23. Testing Mobile Apps
  24. Test Case “Rules” - Good Compiled List on Rules for Writing / Auditing Test Cases
  25. Mobile Application Testing - Part I
  26. Mobile Application Testing - Part II
  27. Mobile Application Testing - Part III
  28. [Good Session] - Mobile WebDriver Testing at TheLadders
  29. Test Mobile applications with COP (who) FLUNG GUN
  30. The Pragmatic Tester - Mindmap
  31. Testing In The Automation Age - Mindmap
  32. The Art of Writing Effective and Transparent Test Cases
  33. Misconceptions about testing (and what we should do about them)
Hope it helps!!


Happy Reading!!

November 15, 2010

Notes for SQL Server Developer

Below post is summary of SQL Server related posts.
  1. Basics – Isolation Levels
  2. Triggers, Procedures, Views - SQL Server Views Revisited
  3. Table Partitioning - Basics, Partition Elimination in SQL Server 2005
  4.  Understand Query Execution process 
  5.  Locking, Blocking, Deadlocking - Blocking Vs Deadlocking, Deadlock Troubleshooting
  6.  SSIS, SSRS, CDC 
  7.  JOINS - Operators - Revisited, SQL Server Indexes and Join Analysis
  8.  DB Replication - SQL Server 2005 Replication Learning’s, SQL High Availability Links
  9.  SQL Upgrade 2005-2008 - SQL Server 2008 Migration Guidelines
  10.  Query Performance Tuning
  11.  Coding Best Practices - SQL Server Coding Guidelines, TSQL XML Parsing
  12.  Read Subject Matter Expert Blogs (Loads of them bookmarked in SQL Links in the blog)
  13.  Road to become Database Architect
  14.  SQL Server 2008 Notes
  15.  SQL Blog – SQL SME’s Blog
  16.  SQL Tips
  17. Started a BI blog to practice SSIS, SSRS
Hope it Helps!!
Happy Reading!!

November 12, 2010

SQL Server 2008 Basics - Isolation Levels

Couple of years back I was not exactly sure of difference between Isolation levels in SQL Server. I learnt it from Roji & Balmukund. Posting my notes and examples I had to understand it better.

“Pessimistic locking” (where data collisions are assumed and locks taken to prevent conflicting updates) and the four standard isolation levels:
1. Read Uncommitted (also known as “Dirty Read”)
2. Read Committed (the default SQL Server transaction isolation level)
3. Repeatable Read
4. Serializable
STEP 1
USE TestDB
CREATE TABLE Employees(EID int primary key identity,EmpName nvarchar(50),Salary money);
GO
INSERT INTO Employees(EmpName, Salary) VALUES ('Raja', 5500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Raman', 44500);
INSERT INTO Employees(EmpName, Salary) VALUES ('Kanna', 12000);

STEP 2
--Isolation Level - READ UNCOMMITTED
--Dirty reads - Uncommitted/Transaction inprogress would be considered part of transaction
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
BEGIN TRAN
SELECT  * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK

STEP 3
--SESSION 2
USE TestDB
GO
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
UPDATE Employees SET Salary = Salary * 1.2
WAITFOR DELAY '00:00:10'
ROLLBACK

STEP 4
--Execute SESSION 2 and then SESSION 1. Below is the output of SESSION 1


Isolation Level - Lost Updates
Nonrepeatable Read: If somebody performed UPDATE or DELETE of any of the rows you read earlier.
Read Committed - When SQL Server executes a statement at the read committed isolation level, it acquires short lived share locks on a row by row basis.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK

STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
COMMIT
STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1


Phantom Reads
Repeatable read - a repeatable read scan retains locks on every row it touches until the end of the transaction.
Phantom: If anybody INSERTed a row within the range you had for an earlier query (i.e., you see new rows).

STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK

STEP 2
--SESSION 2
BEGIN TRAN
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee', 500);
COMMIT

STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1


SERIALIZABLE Isolation Level
--Locks all data in the Range, They remain locked until transaction is Complete
SERIALIZABLE - instead of the simple shared lock that was there with the REPEATABLE READ level, you now have RANGE shared locks (looks like 'RangeS-S, which means a range shared lock for a range scan). You will only see these type of locks when you are using a serialized transaction...these differ from the REPEATABLE READ level locks in that not only do they protect the exact key values returned from the statement, but they also protect the entire range of values the query scans and won't allow the phantom inserts within the queried range like the REPEATABLE READ level did.
STEP 1
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
ROLLBACK

STEP 2
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT

STEP 3
Execute SESSION 1 and then SESSION 2. Output of SESSION 1


Snapshot Isolation and Read Committed with Snapshot Isolation (RCSI).
These impacts are:
  • Increased I/O to manage row versions
  • Increased tempdb usage
  • Changes to default behavior affecting applications that rely on pessimistic locking to implement ordered queues.
STEP 1
ALTER DATABASE TestDB SET ALLOW_SNAPSHOT_ISOLATION ON;
GO

STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN
--Results #1 and #2 will be same, Before starting transaction the latest available data copy would be used as Reference

STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT

STEP 4
--Execute SESSION 1 and then SESSION 2. Output of SESSION 1


Read Committed Snapshot Isolation
  • Statement Level Row Versioning Results for #1 and #2 will differ
  • Before executing each statement it takes a copy
STEP 1
ALTER DATABASE TestDB SET READ_COMMITTED_SNAPSHOT ON
GO

STEP 2
--SESSION 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
SELECT * FROM Employees
WAITFOR DELAY '00:00:10'
SELECT * FROM Employees
COMMIT TRAN

STEP 3
--SESSION 2
BEGIN TRAN
UPDATE Employees
SET Salary = Salary * 1.2
INSERT INTO Employees(EmpName, Salary)
VALUES ('New Employee Again', 800);
COMMIT
STEP 4
Execute SESSION 1 and SESSION 2. Output of SESSION 1
STEP 5
Query to check for Database Status

SELECT snapshot_isolation_state,name
FROM sys.databases

SELECT is_read_committed_snapshot_on ,name
FROM sys.databases


More Reads
Concurrency Series: Basics of Transaction Isolation Levels
Visualising Isolation Levels

Happy Reading!!

TSQL Interesting Questions

Listed below are few TSQL Interesting code snippets and output also provided below the examples. Output I observed in SQL 2008 R2 version.

Example #1
declare @i int
select @i = -5
select +@i
Output: -5

Example #2
declare @i varchar
select @i = 'This is a test'
select @i
Output: T

Example #3
declare @val char(30)
set @val = 'SSc is cool'
select len(@val)
Output: 11

Example #4
declare @val as float, @val1 as float
set @val = 2.0
set @val1 = 1.4
select @val1+@val as sum
Output: 3.4 

Example #5. Minimum of each coulmn

create table #i ( i int, j int, k int)
insert #i values(1, 2, 3)
insert #i values(1, 3, 2)
insert #i values(2, 1, 3)
insert #i values(2, 3, 1)
insert #i values(3, 1, 2)
insert #i values(3, 2, 1)
insert #i values(1, 2, 1)
insert #i values(1, 1, 1)
insert #i values(1, 0, 1)

select (case when (i <= j and i <= k) then i when j <= k then j else k end)
from #i

Example #6. Greatest value of 3 columns. Here's an example of what you want using a derived table

declare @t table(id int, val1 int,val2 int,val3 int)
insert into @t(id,val1,val2,val3) values(1,100,200,300)
insert into @t(id,val1,val2,val3) values(2,300,400,500)
insert into @t(id,val1,val2,val3) values(3,600,700,800)

select id,max(vals)
from
(
   select id,val1
   from @t
union all
   select id,val2
   from @t
union all
   select id,val3
   from @t
) X(id,vals)
group by id

Example #7. Maxof All 3 columns

select max(vals)
from
(
   select A
   from #min
union all
   select B
   from #min
union all
   select C
   from #min
) X(vals)

Thanks to authors of this problems. I am not sure where I read this 'C' Programming Style Problems. I found it interesting.