Create test data in Windows

Posted: November 11, 2010 in Technical
Tags: , , , ,

Using VB scripts is one of the easiest ways of creating test data in Windows environment. I usually use this technique to create file based test data. This is quite an efficient and effective method of creating test data with XML, EDI, Flat etc like file types.

Here what you all have to do is create a VB script and name it as ‘filename.vbs’, place it somewhere in your Windows machine and double click the file to execute it.

I’ll try to elaborate 2 simple methods of creating test data;

Method 01

Create a large test data file by duplicating a part of content within the same file (with certain changes in relevant areas to gain the uniqueness of test data)

Sample test file

sample_01.xml

sample_01.xml

Requirment

Create multiple packages while keeping the uniqueness of the data (Assumption: within the <Order>, ‘n’ number of <Package> can be available)

Solution

In this case, we just build the required test data file from scratch within the VB script. Here you can change the ‘numOfPackages’ variable to get the desired number of packages in the resultant file.
solution_01.vbs

solution_01.vbs

Output

output_01.xml

output_01.xml

 

Method 02

Create large number of test data files by duplicating a particular sample file (produced files should contain unique data)

Sample test file

sample_02.xml

sample_02.xml

Requirment

Create multiple files with unique packages (‘n’ number of files with 1 unique package included in each file)

Solution

In this case we use sample test data file as a template and produce required test data files based on it. You can change ‘numOfFiles’ variable to produce the desired number of files.

solution_02.vbs

solution_02.vbs

Output

output_02_1.xml

output_02_1.xml

output_02_2.xml

output_02_2.xml

output_02_3.xml

output_02_3.xml

Advertisement
Comments
  1. Alex Maksimenkov says:

    useful thing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s