Você está na página 1de 4

ISSN 1866-5705

www.testingexperience.com free digital version print version 8,00 € printed in Germany 12

The Magazine for Professional Testers

Open Source Tools


December 2010

© diego cervo - Fotolia.com


© Stephan Koscheck - Fotolia.com

Populating your database


with a few clicks
by José Carréra

A common obstacle frequently faced by the testing team is the A couple of months ago I was introduced to the Data Generator
challenge of having to check several testing scenarios which re- tool, which according to the website www.generatedata.com is
quire very large amounts of data that could take months to be „a free, open-source script written in JavaScript, PHP and MySQL
obtained in a real production environment. Also, depending on that lets you quickly generate large volumes of custom data in a
the domain of the application, it may just not be possible to have variety of formats for use in testing software, populating databa-
the data made available from production environment due to se- ses, and scoring with girls“. I still haven‘t discovered how the tool
curity or privacy issues. Therefore, quality assurance teams need may help you „score with girls“, but it sure is a great tool to assist
to find other ways to simulate these scenarios as closely as pos- software testing in populating databases.
sible to real environments, whilst at the same time they usually
face strict time constraints, which makes their work even harder. In this article I will describe the main features of this application,
pointing out ways to better use these features based on our pre-
Test engineers have at their disposal some solutions to deal with vious experience using Data Generator in our projects.
this matter. However, they are not always easy to use or are not
fast enough. A commonly used approach is to create SQL scripts
First Look and Installation
manually using a text editor, which is a tedious task that consu- The first great thing about the Data Generator tool is that you
mes a lot of time. Another possibility is to use specific tools to aid can try it out without having to install it. After accessing the
in this task, allowing the user to quickly and easily generate large application‘s website www.generatedata.com and clicking on
amounts of data. However, it is not easy to find a suitable open- the Generator tab, you will be presented with that same web GUI
source tool that is flexible enough to adapt to any type of scenario that you will have if you later on decide to install it locally on your
and all data types. machine. The only constraint is that using this “demonstration”

Image 1 - Website Generator version

82 The Magazine for Professional Testers www.testingexperience.com


version you can only create a maximum of 200 records at a time,
whereas with the locally installed version you may reach 5000 re-
cords at a time.

To install it locally on your machine only a few simple steps need


to be performed. By clicking on the download tab at the website
you can see what the system requirements are:
• MySQL 4+
• PHP 4+
• Any modern, JS-enabled browser

To fulfill these requirements we installed WampServer (www.


wampserver.com), another free, open-source project, which al-
lows us to run Data Generator and all its features. After installing
WampServer just a couple more steps need to be performed. To
start running Data Generator locally on your machine, a simple
five- step installation procedure is available via the download tab
of the application‘s website. For Data Generator version 2.1, which
is the version we used in our projects, the required steps are: Image 2 - Available data types

1. Download the zip-file at the top and unzip the contents lo-
cally on your computer. Explaining its main features
2. In the zip-file, you‘ll find a file in the /install folder named First, I will describe how we can use the pre-loaded user databa-
db_install.sql. This contains all the SQL to create the MySQL
se to generate data. Almost all applications have a user manage-
tables and raw data used by the Data Generator (names, ci-
ment feature that uses data like name, phone, e-mail, address,
ties, provinces, states, countries, etc). You will need to execu-
te these statements on your database through any database etc. It is also common that at some point during the project life
access tool, such as phpMyAdmin. cycle we need to use a larger amount of user data, in order to as-
sess how the system behaves in different test scenarios that may
3. Edit the global/library.php file. At the top, you‘ll see a sec-
focus on features like response time, data integrity, general user
tion where you need to enter your MySQL database settings.
interface, and many others.
Note: if you choose to change the database prefix, make sure
you rename the tables after running the SQL in #2!
On the Data Generator main screen you will be able to define on
4. Upload all files to your web server. each row a data type for each column of the table that you want
5. Upload it to your web browser and get to work. to populate. For each row, the user can define a column title and
its data type along with its specific settings. Different types of
After this small procedure, you can start using Data Generator. pre-loaded data types will be available like: name, phone/fax, e-
As we will describe in the next section, it comes with a pre-loaded mail, city, and others. These data types allow us to solve different
database that might help you in several test scenarios. issues, by attending various test scenarios.

Image 3 - Dates / pre-defined formats

www.testingexperience.com The Magazine for Professional Testers 83


Among the pre-loaded data types, the “Date” option is one of the
most useful, presenting a relevant group of variations, as shown
in image 3. The “Date” option allows us to solve a common pro-
blem faced when generating data, which is that each database
management system uses different date formats. With this defi- Image 5 - Results settings
ned data type, we can solve this issue with a few clicks selecting a
date format and setting the desired date interval. its features, adding new ones, fixing bugs or just by exchanging
ideas with developers and providing important feedback for fu-
The pre-loaded data can be used in isolation or together with ture releases.
custom data types like alpha-numeric and custom lists, which
are two different data types available where the user can enter
Conclusion
specific custom values. If you select custom list, you can choose Technologies applied on software projects get more complex eve-
among some pre-loaded available lists like: marital status, colors, ry day, along with a greater challenge for quality assurance teams
titles, company names, etc., or you can define a customized list to assist the development team in releasing products with higher
by entering values separated by a pipe | character. You may also quality standards, capable of complying with user needs and ful-
define before generation the number of values that you want to filling expectations.
be included in each record.
To achieve these demands, the usage of tools to assist the work
You can also choose alpha-numeric data types, where you can eit- performed by the quality assurance team is primordial. Allowing
her define a specific static value which will be repeated for each engineers to provide faster and more accurate results to their
created record or use its feature that allows the generation of projects, Data Generator seems to be a great option, providing
random values. To do so, you need to follow some defined rules test teams with a suitable solution for populating databases.
presented below in image 4. For instance, if you set the value field
to LLLxxLLLxLL, records will be generated replacing the ‚L‘ for ran- In this article, we presented the main features of Data Generator.
dom upper-case letters and the ‚x‘ for any number from 0 to 9. Special thanks go to Benjamin Keen, responsible for the develop-
ment and distribution of the tool. For further information regar-
ding this tool or the challenges that it might help solving, please
contact the author.

Image 4 - Alpha-numeric data type rules

Another important and useful data type available is the auto-


increment, which we can use to generate a unique number for
each row by incrementing an initial configured value by whatever
value you enter. This functionality is very helpful for setting nu-
meric values commonly used for primary keys on database tables.

Finally, we present the settings that are available for genera-


ting records. Initially, the user can choose among the different
Biography
exporting formats, a feature which has shown to be very useful José Carréra, MSc, is a test engineer at C.E.S.A.R. (Re-
considering that we might use the generated data in different si- cife Center for Advanced Studies and Systems) since
tuations, like using it to import via the application‘s front-end (if 2006 and Professor of Computer Science at FATEC
available) or data importing directly via the system‘s DBMS (Data (Faculdade de Tecnologia de Pernambuco), Brazil,
Base Management System). We can also choose betweem diffe- since 2010. He obtained his master degree in soft-
rent settings of the pre-loaded database, choosing which country ware engineering (2009), graduated in computer
we want the records to be retrieved from, allowing more precise science (2007), and is a Certified Tester — Founda-
tion Level (CTFL), by the ISTQB® (International Soft-
information. Last but not least, we must define the number of
ware Testing Qualifications Board - 2009). His main
results or records that we need to be generated for the selected research interests include quality assurance, Agile
configuration (as mentioned before, we can reach 5000 records methodologies, software engineering, performance
at a time with the locally installed version). testing, and exploratory testing.

Remember that I am not trying to describe a perfect tool that can


solve all your problems. You might find some drawbacks, limita-
tions and also find yourself having to adapt the available data ty-
pes to your needs. However, that’s the great thing about an open-
source project; you can help to make it get better by improving

84 The Magazine for Professional Testers www.testingexperience.com