Generating Test Scenarios from Common Patterns
With the Eclipse client, it is possible to generate a test scenario for a component directly from the Repository view. Two types, or patterns, are available.
- A Simple test scenario contains just one component execution.
- An Iteration with data in Excel sheet option will generate a Microsoft Excel spreadsheet to maintain variable input and expected output values for a component and it will generate a test scenario that uses the Excel spreadsheet to iterate through rows of test data and execute the component. This pattern is very helpful when you want to create a test scenario where the same component must be executed with different input values and expected output values.
Complete the following steps to create a test scenario for the XARISCAL program that will use the Iteration with data in Excel spreadsheet pattern
- Find the XARISCAL component in the Repository view, right-click it and choose Create Total Test Scenario. The Create new Total Test Scenario wizard displays.
- Fill in the values required in this dialog box. Here are the fields available when setting up this element:
Folder - must be an existing project folder. Click Browse to pick the desired location.
- File name - attribute that specifies your Test Scenario name (default name of selected component in the Repository).
- Test scenario type -
- Simple -
- Iteration with data in Excel sheet - Select this option for this example.
- Click Next. The Select Component fields popup displays. This is where you will select the fields that should iterate data from Excel sheet and click Add Input or Add Expected to add a column to the Excel sheet.
- At the Select Component fields page, do the following actions:
- Select the age input field and click Add Input to add this field as input field to the Excel spreadsheet.
Select the risk field and click Add Expected to add this as an expected value to the Excel spreadsheet.
Click Finish.
Now an Excel spreadsheet (*_data.xls or *_data.xlsx) and a test scenario (*.scenario) are being created in the selected target project in the Scenarios folder.- Do one of the following
- Click OK to continue processing. When the maximum of 3000 data items is reached, the 3000 data items are saved while the remaining data items are discarded.
OR - Click Cancel to stop processing at 500 data items and saving the 500 data items while the remaining data items are discarded.
- Click OK to continue processing. When the maximum of 3000 data items is reached, the 3000 data items are saved while the remaining data items are discarded.
- Open the generated spreadsheet (*_data.xls).
The generated spreadsheet contains two columns, one for the input parameter and one for the expected output parameter. - Change the input and expected values as illustrated in the following image.
- This is what your *.scenario will look like:
- Execute the test scenario (*.scenario) and see that it will automatically iterate through each testcase in the Excel spreadsheet, assign the values of the age input column to the input age parameter and compare the value of the risc output parameter with the values defined in the risc_expected column. Refer to Execute Test Scenarios for more information on the Execution Context dialog box.
- Have a look at what the generated test scenario looks like:
- For each additional Iteration, click on the Element in the left column to see its results.
First, a Variable element has been generated and points to the Excel spreadsheet. As you can see in the above illustration, the data from the Excel spreadsheet has been read by the Variable. Then the test scenario contains an Iterate element that will iterate though all test scenario rows in the variable. Inside the Iterate element is a Component that will execute the XARISCAL component. It has automatically been setup with references to the input / expected output values defined in the Excel spreadsheet/variable, so there are no changes required to be done.
For real components, it will often be necessary to define data for several input fields for the component. When a field always has the same value, it can be defined statically in the Component element instead, while fields that change should be defined in the spreadsheet.
This section provides information about the following topics: