|
Data Driven Testing |
Top Previous Next |
|
Purpose Data Driven Testing is an automated testing technique in which test case data is separated from test case logic. Each set of test case data consists of input values and a set of expected output values. The actual output values are compared to the expected output values to determine whether the test passed.
Usage The Spreadsheet object is useful for implementing data-driven tests. It allows you to connect to, query, and read an excel spreadsheet from your test script. To create a data-driven test, you will:
function Test() { //Set Text Inflectra in q SeS('Obj1').DoSetText("Inflectra"); //Click on btnG SeS('Obj2').DoClick(); } The actions recorded were: (1) Type Inflectra into the search box. (2) Press the Google Search button.
function Test() { function Logic(searchterm){ //our new function encapsulates the test logic //Set Text using searchterm SeS('Obj1').DoSetText(searchterm) //here we changed a hard-coded value into a variable //Click on btnG SeS('Obj2').DoClick() } Logic("Inflectra") //don't forget to call your new function }
In our google example, we only have one input value (searchterm) and we're not comparing any expected output values, so we will only need one column in our spreadsheet. Save the spreadsheet in the test folder as searchterms.xls:
Use "Add File(s)..." to add a spreadsheet to the test files:
Drag the 'searchterms.xls' from files tree into appropriate place in your test source:
In our example, we use a Spreadsheet object and run the test logic once for every row. function Test() { function Logic(searchterm){ //Set Text searchterm in q SeS('Obj1').DoSetText(searchterm) //Click on btnG SeS('Obj2').DoClick() }
Spreadsheet.DoAttach('searchterms.xls', 'Sheet1');
// Go through all rows while(Spreadsheet.DoSequential()) { // Read cell value from column 0 var term = Spreadsheet.GetCell(0); // Pass it into Logic function Logic(term); } }
|