Core Step dataDriven
Description
This is an Ant task that calls its nested element as often as specified by the tableContainer. In each run a new set of properties from the the tableContainer is made available to the nested steps
This is the integration into WebTest of the propertyTable task that is available since a long time in WebTest Wiki. You may find usefull to look at this documation because it is currently more complete than this current page.
Parameters
- tableContainer
- Required? yes
- The container for the table containing the data. Typically this is the path to an Excel file but this can also be a directory structure.
- description
- Required? no
- The description of this test step.
- failASAP
- Required? no, default is false
- Indicates if the task should fail at the first failure of the nested content (when set to true) or continue the execution for all records and then throw a BuildException when one or more error occurred (when set to false).
- filterclass
- Required? no, default is FirstEquals
- The filter to apply on the foreign table after the lookup. One of "All", "Empty", "FirstEquals", "AllEquals" or "Group".
- replaceProperties
- Required? no, default is no
- Specifies whether properties contained in the table's values should be expanded or not
- table
- Required? no, default is the first table
- The name of the source table in the current container. For instance the name of the sheet when the table container is an Excel document.
Nested Parameters
- task
- Required? yes
- Any Ant task.
Details
Imagine an Excel file like this one:
You can use dataDriven to execute a set of Ant tasks for each property set:
dataDrivenEcho.xml
<dataDriven tableContainer="simple.xls">
<echo message="Hello ${FirstName} ${LastName}"/>
</dataDriven>
<echo message="Hello ${FirstName} ${LastName}"/>
</dataDriven>
This will give you following output:
[echo] Hello Denis N. Antonioli
[echo] Hello Dierk König
[echo] Hello Marc Guillemot
[echo] Hello Paul King
[echo] Hello Tomi Schütz
[echo] Hello Dierk König
[echo] Hello Marc Guillemot
[echo] Hello Paul King
[echo] Hello Tomi Schütz
Naturally you can combine it with WebTest, lets say to register these persons to some event:
dataDrivenWebtetst.xml
<dataDriven tableContainer="simple.xls">
<webtest name="Register ${FirstName} ${LastName}">
... go to registration page ...
<setInputField forLabel="First name" value="${FirstName}"/>
<setInputField forLabel="Last name" value="${LastName}"/>
<clickButton label="Register"/>
<verifyText text="${FirstName} ${LastName} has been registered"/>
</webtest>
</dataDriven>
<webtest name="Register ${FirstName} ${LastName}">
... go to registration page ...
<setInputField forLabel="First name" value="${FirstName}"/>
<setInputField forLabel="Last name" value="${LastName}"/>
<clickButton label="Register"/>
<verifyText text="${FirstName} ${LastName} has been registered"/>
</webtest>
</dataDriven>