Вы находитесь на странице: 1из 4

printed in Germany

free digital version

www.testingexperience.com

ISSN 1866-5705

12

The Magazine for Professional Testers
The Magazine for
Professional Testers

December 2010

Open Source Tools print version 8,00 €
Open Source Tools
print version 8,00 €

© diego cervo - 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 find 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 with this 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 specific tools to aid

in this task, allowing the user to quickly and easily generate large

amounts of data. However, it is not easy to find a suitable open- source tool that is flexible enough to adapt to any type of scenario and all data types.

© Stephan Koscheck - Fotolia.com

Populating your database with a few clicks

by José Carréra

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 first 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”

The only constraint is that using this “demonstration” Image 1 - Website Generator version 82 The

Image 1 - Website Generator version

82

“demonstration” Image 1 - Website Generator version 82 The Magazine for Professional Testers

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:

1. Download the zip-file at the top and unzip the contents lo- cally on your computer.

2. In the zip-file, you‘ll find a file in the /install folder named db_install.sql. This contains all the SQL to create the MySQL tables 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 database access tool, such as phpMyAdmin.

3. Edit the global/library.php file. 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 prefix, make sure you rename the tables after running the SQL in #2!

4. Upload all files 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.

database that might help you in several test scenarios. Image 2 - Available data types Explaining

Image 2 - Available data types

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 different 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 define on each row a data type for each column of the table that you want to populate. For each row, the user can define a column title and its data type along with its specific settings. Different 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 different issues, by attending various test scenarios.

solve different issues, by attending various test scenarios. Image 3 - Dates / pre-defined formats

Image 3 - Dates / pre-defined formats

www.testingexperience.com

The Magazine for Professional Testers

test scenarios. Image 3 - Dates / pre-defined formats www.testingexperience.com The Magazine for Professional Testers 83

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- 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 different data types available where the user can enter specific 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 define a customized list by entering values separated by a pipe | character. You may also define 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 define a specific 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 defined rules presented below in image 4. For instance, if you set the value field 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.

letters and the ‚x‘ for any number from 0 to 9. Image 4 - Alpha-numeric data

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 exporting formats, a feature which has shown to be very useful considering that we might use the generated data in different 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 diffe- 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 define the number of results or records that we need to be generated for the selected configuration (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 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

project; you can help to make it get better by improving 84 The Magazine for Professional

The Magazine for Professional Testers

better by improving 84 The Magazine for Professional Testers Image 5 - Results settings its features,

Image 5 - Results settings

its features, adding new ones, fixing 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- filling 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.

that it might help solving, please contact the author. Biography José Carréra, MSc, is a test

Biography

José Carréra, MSc, is a test engineer at C.E.S.A.R. (Re- cife Center for Advanced Studies and Systems) since 2006 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 computer science (2007), and is a Certified Tester — Founda- tion Level (CTFL), by the ISTQB® (International Soft- ware Testing Qualifications Board - 2009). His main research interests include quality assurance, Agile methodologies, software engineering, performance testing, and exploratory testing.

www.testingexperience.com