How to build test XML documents fast and easy?

The XML is a very popular format of system interconnection in the modern world. It can be used as a common format for different software solutions as well as a part of communication protocols.

The developers who work with XML often have to spend hours of work to create test documents with various properties. A lot of documents with a wide range of each item value required for testing purposes. At the other hand, test XML files must keep the realistic property. It is wrong way to use "12345" instead phone number or "abcd" instead of the realistic e-mail address.

The next aspect of test XML document creation is a number of different files. It is impossible to make thousands of documents manually as well as generate really different documents by the simple script.

The XML generator requirements

DTM Test XML Generator: document structure tree

DTM Test XML Generator was designed as alternative for manually test creation and in-house scripting for test XML data. There are main requirements for this kind of tool we have:

  1. Quick start. It should have import existing XML file structure.
  2. Easy structure modification. At the design time, the developers can modify the schema of XML document too often.
  3. Powerful data generation methods including database, another XML and text files as a source of the test data.
  4. Preview feature for generated document as a part of the user interface.
  5. High performance to create thousands of test files in acceptable time.

Let us describe how we achieved mentioned goals in DTM Test XML Generator tool.

To make start quick and easy the program can import structure from existing XML document and assign data generators for each node and attribute automatically. It analyzes item name and data to make value be generated more realistic. Also, the software supports import document structure from XSD schemas. For the new files, the user allowed entering the structure manually.

DTM Test XML Generator: custom generator with pattern engine call

The software has a complete set of structure modification options. The user can create a new node, rename or drop existing one. The same operations are available for the attribute as well as change item order options.

Test Value Generation Methods

DTM Test XML Generator offers two blocks of data generation methods. The first block is a set of predefined data generators like address, e-mail, phone number, currency or country code. Currently, the program has 25 predefined generators. The second is a pattern engine, i.e. built in data generation language. "Custom generator" item in the generators menu helps users to access the pattern engine.

The default connection feature is a way to use database data (tables or queries) as a source in the data generation process. $Table and $Query functions of the pattern engine retrieve data from table and SQL statement including stored procedure or built-in DBMS function call.

DTM Test XML Generator: preview feature

Database Integration: Default Connection and Scripts

An important option related to default database connection is prologue and epilogue scripts. These SQL scenarios can help to prepare the database for data generation and clean it up after project execution. The example, a temporary database can be filled out by actual data from production one.

The preview helps users to analyze sample generated XML document by one click. It shows the generated document with complete hierarchy.

To analyze the software performance we created simple XML structure with typical values: random integer, auto incremental value, random date, random time, etc. At the office PC, the performance is about 160 XML files per second for 5,000 file set.