Data files
The Storefront Test Automation Engine includes a sample mechanism to load values from XML data files. Having separate data files lets developers isolate the logic of their tests from the data they are testing. It also makes it possible to reuse a test case using multiple sets of data.
Note: You do not have to use the data file mechanism; there
are many ways to load data in a test.
Data file structure
An XML data file contains
the following nodes:
- <Scenario> node: The root node of the XML document; it contains a single <Env> node and one or more <Test> nodes.
- <Env> node: Contains parameters that are shared across all tests and data blocks. It contains a list of <Parameter> nodes.
- <Test> nodes: Represent the data associated with a test case. The test nodes must contain a unique name in the data file. The <Test> nodes contain a list of <Datablock> nodes.
- <Datablock> nodes: Contains the data associated with a part of a test case. The name of a datablock must be unique within a <Test> node. <Datablock> nodes contain one <Input> node and one <Output> node.
- <Input> node: Contains a list of <Parameter> nodes associated with the inputs required to perform a test case.
- <Output> node: Contains a list of <Parameter> nodes associated with the outputs produced by a test case.
- <Parameter> node: Contains a parameter required for a test. <Parameter> nodes must contain a unique name within their group and a value.
<?xml version="1.0" encoding="UTF-8"?> <Scenario name="SCENARIO_NAME"> <Env> <Parameter name="SHARED_1" value="value 1" /> <Parameter name="SHARED_2" value="value 2" /> </Env> <Test name="TEST_1"> <Datablock name="BLOCK_1"> <Input> <Parameter name="PARAMETER_1" value="value 1.1" /> <Parameter name="PARAMETER_2" value="value 2.1" /> </Input> <Output> <Parameter name="PARAMETER_1" value="value 3.1" /> <Parameter name="PARAMETER_2" value="value 4.1" /> </Output> </Datablock> <Datablock name="BLOCK_2"> <Input> <Parameter name="PARAMETER_1" value="value 1.2" /> <Parameter name="PARAMETER_2" value="value 2.2" /> </Input> <Output> <Parameter name="PARAMETER_1" value="value 3.2" /> <Parameter name="PARAMETER_2" value="value 4.2" /> </Output> </Datablock> </Test> <Test name="TEST_2"> <Datablock name="BLOCK_1"> <Input> <Parameter name="PARAMETER_1" value="value 1.3" /> <Parameter name="PARAMETER_2" value="value 2.3" /> </Input> </Datablock> </Test> </Scenario>