Sophisticated applications may need to test the same script using a whole range of values for their input. For example you may want to test all the boundary conditions for an operation – what happens when somebody orders quantities of 0, 5, 10, 1000 of a particular item? Or perhaps you want to test that ordering of every item in your warehouse works. Doing these kind of operations where you want to run the same script over many different values for a parameter (or variable) is greatly eased by connecting your scripts to a Data Source.
Badboy supports reading values for variables through ODBC. This means that if you set up an ODBC data source (which could be anything from an Oracle database to a comma separated text file) then Badboy can read variable values from it and when variables are incremented in your script they will iterate through the values in your source.
This help uses an Excel file as an example – but remember that you can use any ODBC source.
Data Source Requirements
By default Badboy requires data sources to satisfy certain requirements. (Note: you can change or avoid these requirements if you know how to write SQL for your Data Source. See the information on Using Custom SQL later in this topic for more information.)
Here is how an example Excel spreadsheet satisfying these criteria might look:
This shows how you would create an excel file to load values for variables “Pieces” and “weight”. Note that all names are case sensitive, and that in some cases the ODBC may convert the names to upper case without asking you. You will need to experiment with your data source to get this right.
Sometimes you might find that the wrong part of your spreadsheet gets exported by Excel to Badboy, or even a subset of the rows you want or nothing at all. The solution to this is to define the area you want Excel to export by selecting it and pressing Ctrl-F3. Then you can give it a name and when you configure the data source in Badboy the name should show up for you to choose as a table. This allows you to choose exactly the rows you want from your spreadsheet and ensures that Excel sends the correct data.
Adding a Data Source
Data Sources are configured in Badboy by adding "Data Source" items from your Toolbox into your script.
The image below shows how a Data Source item looks after adding to a script:
Setting the Properties
When you add a Data Source item to your script you will be given a choice of all the ODBC data sources on your system. Some data sources must be set up in advance using the Control Panel on your computer (from the Start menu choose Settings->Control Panel and look for the “Data Sources” applet, which may be under Administrative Tools depending on your version of windows). Other data sources, for example Excel files, can be accessed directly from Badboy. For Excel files there should be an “Excel Files” option in the drop down menu (you must have Excel along with its ODBC drivers installed). Select this option and Badboy will read the file and show you the worksheets inside.
You should then select the worksheet from which you would like Badboy to load values. Once you have selected the worksheet, Badboy will return you to the Data Source Properties page where you can select other preferences for how data should be loaded. The diagram below shows the Properties page for configuring a Data Source:
Controlling the Format of Loaded DataYou can review how the loaded data will look by clicking the "Format..." button. This will cause Badboy to load the data from your Data Source and show it to you. If the values do not appear in the format that you want then you can choose from among some format options on this screen to change how they are loaded.
The diagram below shows an example of this:
Playing Data Source Items
Data is loaded when a Data Source item is played as part of the script execution. Hence after defining your data source you won't see any values loaded until you cause it to be played, for example, by right clicking on the item and selecting 'Play'.
Note: prior versions of Badboy loaded data from data sources when Badboy was started. If you have legacy scripts with data sources attached then they will still behave this way. New scripts, however, should use the methods described in this section.
Using Data Source Values
Badboy will automatically read the next value from your data source each time a variable is incremented. This could be as a result of an auto-increment (performed at the start of the script when a variable is flagged for auto-increment) or as a result of an explicit increment placed in your script.
A very common scenario is to load values from a data source and then repeat a Step for each row of values in the data source. Badboy makes this very easy to do by using the looping properties of Steps. You can do this by taking the following actions:
When you have finished, your Script would look something like the figure below:
Badboy offers some advanced options that you can use to load data in more sophisticated ways. These are: