Saturday, November 14, 2009

Data Driven Frameworks

Data Driven frameworks, as the name suggests, are those where the test input data drives the test. There would be data driven scripts which contain a high level of hardcoded areas, with variable data. Hence the data driven scripts are mostly Application Specific. The same framework cannot be used across different applications to test them. This puts a limitation on people adapting data driven frameworks for testing their applications, but these frameworks could be used to perform an exhaustive testing of your application.

Data Driven Frameworks could be therefore defined as a set of application specific scripts which tests and validates the application against application data. Consider the following architecture of a sample framework.

 Fig: A Sample Data Driven Framework

Here, the data pool would contain the data necessary for testing the application. This includes both the input data, as well as the data for result analysis. There will be a large amount of Hardcoded part in the script, apart from the varying data input section.

Let me explain this in an easier way. If we design a data driven framework to test a website namely, we cannot test another similar website like with the same framework. The reason behind this is that the scripts that we use will include sections where the object names of the google web page, which are hardcoded in our framework.

Now, let me just show an example where the test case checks the second page for the search keyword. Find the following VBScript code. The code just tests the google search. You can download the code and input file here (

The Code:

Dim IE, strTestInput(100), strTestVal, strActualResult, strTextFile, intCount, i

'Setting the Folder Path
Path = Replace(Wscript.ScriptFullName, Wscript.ScriptName, "")

'Reading the inputs from Text File
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(Path&"testinput.txt") Then
    Set strTextFile = FSO.OpenTextFile(Path&"testinput.txt", 1, True)
    intCount = 0
    Do Until strTextFile.AtEndofStream
        strTestInput(intCount) = strTextFile.Readline
        intCount = intCount + 1

    'Performing the Search on Google
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    i = 0
    Do Until i = intCount
        IE.Navigate ""
            Do Until IE.ReadyState = 4
                Wscript.Sleep 1000
        IE.Document.GetElementByID("q").Value = strTestInput(i)
        Wscript.Sleep 3000
        strActualResult = IE.Document.GetElementByID("q").Value

            If StrComp(strActualResult, strTestInput(i)) = 0 Then
                MsgBox "Pass!!"
                MsgBox "Fail!!"
            End If
        i = i + 1

    Set IE = Nothing
    MsgBox "The file "&Path&"testinput.txt"&" does not exist. Please create the file with test inputs before proceeding"
End If

Note: In order to use the code, one should create a text file named “testinput.txt” with the input values.

The fact is that one cannot test another website with this piece of code. The code is specifically for This could be taken as an example of a data driven test script.