Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

Basic Data Table Operation for Data Driven Test


Add This Code to My Favourite List
Enter Email

Contributed By IT Prof
Date 2016-03-12 08:14:59

'Tutorial: itprof_tut
' Basic Data Table Operation for Data Driven Test for Calculator
'Schema of the DataTable
'Operation Val1 Val2 ExpectedResult ActualResult Status
'Add	       2	3	5
'Sub			5	9	-4
'Multiply		7	9	63
'Divide			100	50	2
'Add			56	44	100

'Reading Data from Data Table
sOps =   DataTable.Value("Operation",dtGlobalSheet)
sVal1 =   DataTable.Value("Val1",dtGlobalSheet)
sVal2 =   DataTable.Value("Val2",dtGlobalSheet)
Select Case sOps
	Case "Add"
		'Call Function which will do Add/Sub/Multiply and Divide Operation and will return from result
		sResult = Int(sVal1) + Int(sVal2)
	Case "Sub"
		sResult = Int(sVal1) - Int(sVal2)
	Case "Multiply"
		sResult = Int(sVal1) * Int(sVal2)
	Case "Divide"
		sResult = Int(sVal1) / Int(sVal2)
End Select

'Setting Value in the Data Table
DataTable.Value("ActualResult",dtGlobalSheet) = sResult

If DataTable.Value("ActualResult",dtGlobalSheet) = DataTable.Value("ExpectedResult",dtGlobalSheet) Then
	DataTable.Value("Status",dtGlobalSheet) = "Passed"
Else
	DataTable.Value("Status",dtGlobalSheet) = "Failed"
End If

Download Above Code

Comments:



Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *