Friday, July 24, 2009

Database Testing - Comparing Two Tables Values Through QTP

I was just doing some Database testing using QTP. The following code will check whether both Database tables have equal values. This can be used multiple scenarios, like Two Database comparison, Two or more Table values comparisons, so on.

'Get Two different data from two different Tables and compare it;
'Two different Database and check their values.
' First Table Name - -> EmpTable
' Second Table Name ---> DeptTable
'Database ---> MS Access

' First Table Connection
Dim conn,rs
Set conn=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")conn.provider="microsoft.jet.oledb.4.0"conn.open"C:\db1.mdb"
' creating an object for the recordsetset
rs =CreateObject("ADODB.recordset")
' DB Query for selecting all the records available from EmpTable
rs.open "select * from EmpTable",conn
' Adding Headings
datatable.GetSheet(1).addparameter "EMPLOYEE NO","
"datatable.GetSheet(1).addparameter " NAME","
"datatable.GetSheet(1).addparameter "DESIGNATION","
"datatable.GetSheet(1).addparameter " ADDRESS",""row=1
' Loop for each records
Do While not rs.EOF
datatable.SetCurrentRow(row)
datatable.Value("EMPLOYEE_NO",1) = rs.fields("EmpNo")
datatable.Value("NAME",1)=rs.fields("EmpName")
datatable.Value("DESIGNATION",1)=rs.fields("Designation")
datatable.Value("ADDRESS",1)=rs.fields("Address")
val1 = datatable.Value("NAME",1)row=row +1rs.movenext loop
' Second Table Operation
set rs1 =CreateObject("ADODB.recordset")
'DB Query for selecting all the records available from DeptTable
rs1.open "select * from DeptTable",conn
datatable.GetSheet(1).addparameter "EMPNO_Dept",""
datatable.GetSheet(1).addparameter "EMPNAME_Dept",""
datatable.GetSheet(1).addparameter "DEPTNAME_Dept",""
' Assigning values from First row
row=1
do While not rs1.EOF
datatable.SetCurrentRow(row)
datatable.Value("EMPNO_Dept",1)=rs1.fields("EmpNo")datatable.Value ("EMPNAME_Dept",1)=rs1.fields("EmpName")
datatable.Value("DEPTNAME_Dept",1)=rs1.fields("DeptName")
row=row +1rs1.movenextloop
' Create one more Column called ResultColumn
DataTable.GetSheet("Global").AddParameter"ResultColumn",""
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("NAME","Global")
NewVal = DataTable.Value("EMPNAME_Dept","Global")
' Comparing two NAME fields
If OldVal = NewVal Then
DataTable.Value("ResultColumn","Global") = oldVal
Reporter.ReportEvent micPass, "P","The Names Fields are Equal "
else Reporter.ReportEvent micFail,"F","The Names Fields are Not Equal"
End If
Next

Monday, July 13, 2009

Challenges in Agile Automated Testing

Recently, when I wanted to start my new Automated Testing Project with four resources, I thought of applying any one of the Agile methodologies. But I was not able to continue because, a series of questions were raised inside my mind. The questions are like “Is it possible to use Agile methodologies in Automated Testing?”, “Can I use traditional tools”, “Should I have to go for open-source tools”, “What are the challenges I have to face if I am implementing automation in Agile Environment”. Automated testing in the Agile environment stands a risk of becoming chaotic, unstructured and uncontrolled. I published an article on the same topic in softwaretestinghelp.com