Populating your database with a few clicks
-
Upload
jose-carrera -
Category
Documents
-
view
221 -
download
0
Transcript of Populating your database with a few clicks
8/8/2019 Populating your database with a few clicks
http://slidepdf.com/reader/full/populating-your-database-with-a-few-clicks 1/4
The Magazine for Professional Testers
December 2010
I S S N 1 8 6 6 - 5 7 0 5
w w w . t e s t i n g e x p e r i e n c e . c o m
f r e e d i g i t a l v e r s i o n
p r i n t v e r s i o n 8 , 0 0 €
p r i n t e d i n G e r m a n y
Open Source Tools
12
© diego cervo - Fotolia.com
8/8/2019 Populating your database with a few clicks
http://slidepdf.com/reader/full/populating-your-database-with-a-few-clicks 2/482 The Magazine for Professional Testers www.testingexperience.com
Populating your databasewith a few clicks
by José Carréra
© Stephan Koscheck - Fotolia.com
A common obstacle frequently faced by the testing team is the
challenge of having to check several testing scenarios which re-
quire very large amounts of data that could take months to be
obtained in a real production environment. Also, depending on
the domain of the application, it may just not be possible to have
the data made available from production environment due to se-
curity or privacy issues. Therefore, quality assurance teams need
to nd other ways to simulate these scenarios as closely as pos-
sible to real environments, whilst at the same time they usually
face strict time constraints, which makes their work even harder.
Test engineers have at their disposal some solutions to deal withthis matter. However, they are not always easy to use or are not
fast enough. A commonly used approach is to create SQL scripts
manually using a text editor, which is a tedious task that consu-
mes a lot of time. Another possibility is to use specic tools to aid
in this task, allowing the user to quickly and easily generate large
amounts of data. However, it is not easy to nd a suitable open-
source tool that is exible enough to adapt to any type of scenario
and all data types.
A couple of months ago I was introduced to the Data Generator
tool, which according to the website www.generatedata.com is
„a free, open-source script written in JavaScript, PHP and MySQL
that lets you quickly generate large volumes of custom data in a
variety of formats for use in testing software, populating databa-
ses, and scoring with girls“. I still haven‘t discovered how the tool
may help you „score with girls“, but it sure is a great tool to assist
software testing in populating databases.
In this article I will describe the main features of this application,
pointing out ways to better use these features based on our pre-
vious experience using Data Generator in our projects.First Look and Installation
The rst great thing about the Data Generator tool is that you
can try it out without having to install it. After accessing the
application‘s website www.generatedata.com and clicking on
the Generator tab, you will be presented with that same web GUI
that you will have if you later on decide to install it locally on your
machine. The only constraint is that using this “demonstration”
Image 1 - Website Generator version
8/8/2019 Populating your database with a few clicks
http://slidepdf.com/reader/full/populating-your-database-with-a-few-clicks 3/483The Magazine for Professional Testerswww.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 fulll 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
ve- 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:
1. Download the zip-le at the top and unzip the contents lo-cally on your computer.
2. In the zip-le, you‘ll nd a le in the /install folder nameddb_install.sql. This contains all the SQL to create the MySQLtables and raw data used by the Data Generator (names, ci-ties, provinces, states, countries, etc). You will need to execu-te these statements on your database through any databaseaccess tool, such as phpMyAdmin.
3. Edit the global/library.php le. At the top, you‘ll see a sec-tion where you need to enter your MySQL database settings.Note: if you choose to change the database prex, make sure
you rename the tables after running the SQL in #2!
4. Upload all les to your web server.
5. Upload it to your web browser and get to work.
After this small procedure, you can start using Data Generator.
As we will describe in the next section, it comes with a pre-loaded
database that might help you in several test scenarios.
Explaining its main features
First, I will describe how we can use the pre-loaded user databa-
se to generate data. Almost all applications have a user manage-
ment feature that uses data like name, phone, e-mail, address,
etc. It is also common that at some point during the project life
cycle we need to use a larger amount of user data, in order to as-
sess how the system behaves in dierent test scenarios that may
focus on features like response time, data integrity, general user
interface, and many others.
On the Data Generator main screen you will be able to dene on
each row a data type for each column of the table that you wantto populate. For each row, the user can dene a column title and
its data type along with its specic settings. Dierent types of
pre-loaded data types will be available like: name, phone/fax, e-
mail, city, and others. These data types allow us to solve dierent
issues, by attending various test scenarios.
Image 2 - Available data types
Image 3 - Dates / pre-dened formats
8/8/2019 Populating your database with a few clicks
http://slidepdf.com/reader/full/populating-your-database-with-a-few-clicks 4/484 The Magazine for Professional Testers www.testingexperience.com
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 dierent date formats. With this de-
ned data type, we can solve this issue with a few clicks selecting a
date format and setting the desired date interval.
The pre-loaded data can be used in isolation or together with
custom data types like alpha-numeric and custom lists, which
are two dierent data types available where the user can enter
specic custom values. If you select custom list, you can choose
among some pre-loaded available lists like: marital status, colors,
titles, company names, etc., or you can dene a customized list
by entering values separated by a pipe | character. You may also
dene before generation the number of values that you want to
be included in each record.
You can also choose alpha-numeric data types, where you can eit-
her dene a specic static value which will be repeated for each
created record or use its feature that allows the generation of
random values. To do so, you need to follow some dened rulespresented below in image 4. For instance, if you set the value eld
to LLLxxLLLxLL, records will be generated replacing the ‚L‘ for ran-
dom upper-case letters and the ‚x‘ for any number from 0 to 9.
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 congured 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 dierentexporting formats, a feature which has shown to be very useful
considering that we might use the generated data in dierent si-
tuations, like using it to import via the application‘s front-end (if
available) or data importing directly via the system‘s DBMS (Data
Base Management System). We can also choose betweem die-
rent settings of the pre-loaded database, choosing which country
we want the records to be retrieved from, allowing more precise
information. Last but not least, we must dene the number of
results or records that we need to be generated for the selected
conguration (as mentioned before, we can reach 5000 records
at a time with the locally installed version).
Remember that I am not trying to describe a perfect tool that can
solve all your problems. You might nd some drawbacks, limita-
tions and also nd 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
its features, adding new ones, xing bugs or just by exchanging
ideas with developers and providing important feedback for fu-
ture releases.
Conclusion
Technologies applied on software projects get more complex eve-
ry day, along with a greater challenge for quality assurance teams
to assist the development team in releasing products with higher
quality standards, capable of complying with user needs and ful-
lling expectations.
To achieve these demands, the usage of tools to assist the work
performed by the quality assurance team is primordial. Allowing
engineers to provide faster and more accurate results to their
projects, Data Generator seems to be a great option, providing
test teams with a suitable solution for populating databases.
In this article, we presented the main features of Data Generator.
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 5 - Results settings
José Carréra, MSc, is a test engineer at C.E.S.A.R. (Re-cife Center for Advanced Studies and Systems) since2006 and Professor of Computer Science at FATEC(Faculdade de Tecnologia de Pernambuco), Brazil,since 2010. He obtained his master degree in soft-ware engineering (2009), graduated in computerscience (2007), and is a Certied Tester — Founda-tion Level (CTFL), by the ISTQB® (International Soft-ware Testing Qualications Board - 2009). His mainresearch interests include quality assurance, Agilemethodologies, software engineering, performancetesting, and exploratory testing.
Biography