In my previous post I was talking about parameterization or randomization in our tests, why is it necessary and how to add it in our tests. In this article I would like to talk about a tool that can help us achieve that, a tool that can save us a lot of tedious work.
Let's say we need to do some validation tests on a set of fields in a form that will be displayed on a page after saving them, this fields are:
We need to validate some different things like:
- Text once saved fits the design and it doesn't overflow or overlaps anything
- Min. allowed char.
- Max allowed char.
- Accented or other funky chars (á ç ñ)
- No numbers on Name and LastName fields
- No letters on Phone fields
And we can go on and on and we could end up typing (and thinking about) 100 or 1000 different names, last names, phones, etc but. It wouldn't be better to have a tool that generates all that info for you?
Well, "there's an app for that". One of them is Generate Data it basically generates random data for us to use in our tests. Next I will detail how does it do it.
We have different sections there. Lets start describe each one.
This is the main window of Generate Data. This service is available on their website. However, you can download the project and install it for free, the installation is easy and you just need a basic server (Apache, MySQL, PHP, not sure if also Smarty). Have it installed has it's advantages, you can create accounts and save datasets and also edit the default value of generated datasets.
- Login and Language: Here you can login and change your language preference.
- Data sets saving and managing: From here you can name and save, then call, clear and link to your datasets (Logged in functions only).
- Country-Specific Data Selection: From here you can select which kind of data you can generate... For example, let's say your form accepts just US phones... If you select All Countries some of those phone numbers could not match your validations and could break that field. That could be an intended test.
- Data Sets: This is where you actually construct the data you need, we will get to it later.
- Export Types: Once you constructed the structure of your data. Here is where you select how do you want to get the data. It has different formats to deliver the data and you can get it on the page or via download.
Let's build the data we need. Let's take the example of the beginning... We would need a bunch of Names, Last names, Phones, Addresses, Cities and Countries.
to construct a table that looks something like:
|Gustavo||Rivera||456-789-3598||234 Fake Address||New Hope||USA|
|John||Doe||951-765-3498||048 Fake Address||Warminster||USA|
|Jane||Doe||957-835-9143||94 Fake Address||Doylestown||USA|
Is the order on how the columns are going to be shown... From the example, if we want that same order we should start from left to right populating the fields from up to down as follows on 2
2. Column Title
Since we don't have enough columns here we are going to type 2 on the Add field at the bottom and click the button Row(s)
3. Data Types
Each type of data selected here is what is going to give us the different info we want. Options here are:
- Human Data
- Names, Regional
- Phone / Fax
- Phone / Fax, Regional
- Street Address
- Postal / Zip
- Region (state)
- Latitude / Longitude
- Fixed number of words
- Random number of words
- Number Range
- Normal Distribution
- Tree (parent row ID)
- Custom List
TIP: For knowing what kind of data and some examples you can click on the ? that appears on the column Help (6)
On this column we can specify more detailed info. For example. For the Option Names on Column 3 we can pick Male, Female and Any Gender. When we get the data that would give us just Male names, just Female names or Both. Each kind of data has it's own examples.
Some other type of Data have also more options, and we can specify it on this field. For example, currency.
if we pick currency there, then we can pick from some examples, picking one of them brings us some options, there, we can modify the output of the field and all our data will have the same format we edited there.
6. Help and Deleting
Here we can get Help about the data we are generating, and selecting the check and clicking on Del. Button will delete those fields or columns.
After picking the correct data:
We can now get our data. On the last part of the page we will see the Export types. It can export on different formats.
- Programming language
Each option have their own sub-options, for example on CVS files you can pick the separation char. like comma (,) or pipe (|). On HTML, we can pick if you need an HTML table or an ordered list, or unordered list or even custom format.
On the green section is where we are going to pick how many results do we want. For this example we are going to pick just 10 and then click on New Window/Tab and finally Generate button
What I got was:
Now I can use that data to create a script, or to use it manually by just copy/pasting. How to use generated data in a script? Well, each tool has their on way to do it, I have examples here and here. I hope this tool helps you to save time and effort and to improve your parameterization approach for your next test scripts. In my next article I will talk about Test Spicer that is a similar tool, the main difference between them is that the data sets are generated from API calls that you make directly from your script.