Generating data with Om

As a part of development or quality assurance activities you must have faced situations that require you to test a field of an application by using strings of a particular length (as a part of Boundary Value Analysis) or you need to generate random data to check if an application behaves gracefully when subjected to it (as a apart of random testing).

Generating text data of 100s and 1000s characters or with random characters that includes alphabets [a-zA-Z], numbers and special characters is a difficult and time consuming activity.

“Om” tool comes handy in such situations!

The objective of this article is to make the audiences aware of “Om”, an open source software testing tool that is used for generating text data. It details about all the options the tool provides with relevant examples so that the readers can understand and use the tool easily based on their requirements. The author also suggests its readers to use the tool so that they can reap the benefits provided by it.

Om Overview

Om is an easy to use command line tool developed by Sanket Vaidya that can be used to generate text data for random and field testing. The data generated by the tool gets copied to the clipboard and can be used directly as an input to a text field or can be recorded as test data by pressing Ctrl+V on the keyboard. (‘Ctrl+V’ is the paste option of windows operating system and is used to paste data that is present on the clipboard.) Along with adding the generated data to the clipboard, the tool displays it on the command prompt for user to have a look. This is helpful as the users can validate if the text data generated is consistent with their requirements before pasting it from the clipboard to the desired location (document or field of an application).

Om Download and Installation

Download Om (Om1.1_Setup.tar), unzip it (using WinRAR or 7-Zip) and run the setup file to start the installation. Acknowledge GPL v3 and fdl v1.2 licenses during install and Om gets installed in ‘C:\Program Files\Om’ location on your system.

You can start using Om either by browsing to Start->All Programs->Om or by going to C:\Program Files\Om location on the command prompt.

System Specifications

Binary Size 1.25 MB
HDD/Memory Requirements 6.5 MB (C:\Program Files\Om) / Nothing Specific
Supported Operating Systems Win2000 and later
Supported Locale English

Using Om

When Om is started, it takes the user to the Welcome Screen which looks like this:

*****************************************

*                                                                                        *

*       Om for software testing                                 *

*          by Sanket Vaidya                                          *

*                                                                                        *

*       Type om -h for help                                         *

*                                                                                         *

*****************************************

Key in ‘om –h’ and it displays the help of the tool. ‘help’ is useful in knowing the modes and options with which the tool works.

—————————————————————————————————–

C:\Program Files\Om>om -h

syntax: om [mode] [count] [options]

mode:

R  – Repeat (default)

r  – random

c1 – combined1

c2 – combined2

count: any integer number > 0

options: (not applicable to Repeat mode)

-l – lowercase including space (default)

-u – uppercase including space

-n – numeric

-o – other characters except above three.

-a – all (not allowed with any other option)

om -h: Display this help.

om -v: Display version & Copyright information.

—————————————————————————————————–

Om works with four modes. Let’s discuss them in detail.

R (Repeat Mode)

This mode helps the user in generating data of ‘N’ characters, where ‘N’ denotes the length of text data required by the user.

Example: if the user furnishes ‘Om R 12’ command to the tool, the tool asks the user to enter text which is further used to generate the data. Say, the user enters ‘pattern’ as input. The tool generates a string of 12 characters by repeating the word ‘pattern’. In this case the tool produces ‘patternpatte’ string and chops the ‘rn’ characters of the word ‘pattern’ so that the data is restricted to 12 characters as request by the user.

Same result can be achieved by using the command ‘Om 12’ (without ‘R’) as Repeat mode is the default mode with which the tool operates.

As discussed earlier, Ctrl+V is used by the user to copy the generated data.

Before discussing the other modes, let us first understand the ‘options’ provided by the tool.

As the help suggests, we have the following options:

  1. –l (lower case): When this option is used, the tool generates the text data by using only the characters in the range [a-z] and space.
  2. –u (upper case): Tool generates the text data using characters in the range [A-Z] and space, when this option is used.
  3. –n (digits): Digits in the range [0-9] would be used to generate the text data when this option is used.
  4. –o (other): When this option is used, the tool generates the text data using all other characters apart from [a-zA-Z0-9] and space.
  5. –a (all characters): In this case, the tool generates the text data by using all characters randomly.

Users need to note that:

–      ‘Options’ can be used only in Random and Combined modes of the tool.

–      -l,-u,-n,-a options can be used in conjunction but not with –o option. For example, -lun suggests data generated with characters a-zA-Z0-9 and space but not with other characters.

r (Random Mode)

This mode is similar to the Repeat mode in the way that it generates data of ‘N’ characters but unlike Repeat mode, Random mode doesn’t ask the user to enter the text for producing the data.

Example: For the following command, ‘om r 20 –l’ the tool generates text data of 20 characters by using characters a-z and space (as option –l is used). Text data of this nature (‘mqshuvymtfxjw mvvvum’) would be the output of the tool.

Similarly, ‘om r 20 –u’ or ‘om r 20 –a’ generates text data of 20 characters based on the ‘option’ used by the user.

Command ‘om r 20 –lun’ produces a string that is generated by combining characters, a-z, A-Z, 0-9 and space as options -l, -u and -n are used in combination. ‘h5tHgbewkmaLiSIqT0oa’ would be a sample output of the tool for this command.

c1 and c2 (Combined Mode)

This mode can be considered as a combination of user input and the data generated by the tool in the Random Mode. Basically, in Combined mode, the random data generated by using option or combination of options is prefixed or suffixed by the text entered by the user.

c1 (Combined1 Mode)

Let’s consider an example to manifest the working of the combined1 mode. Command ‘om c1 20 –l’ would ask the user to enter a text. Say, user enters ‘user+’. Then the output generated by the tool would be of format ‘user+djpyhimmawcqxht’. If observed carefully, it could be noted that in c1 mode the random data generated is prefixed with the text entered by the user while maintaining the total length of output to the limit mentioned by the user, in this case 20.

  c2 (Combined2 Mode)

Similar to Combined1 mode, Combined 2 mode is combination of random data and the text entered by the user. The only difference is that, in this case the user text is suffixed to the random data that is generated by using the option or combination of options.

How do I use Om

Om is useful for:

–      Generating text data of specified length. This can be used for Boundary Value Analysis of text field of an application.

–      Producing random strings made by combination of lowercase, uppercase, special characters. This can be used for ad-hoc testing or field testing.

–      For generating random data frequently, if required.

Limitations

–      Om doesn’t throw ‘Invalid syntax’ error if ‘&’ is used as an ‘option’. For example, ‘om r 20 &’ behaves like ‘om r 20 –l’ instead of treating it as an error.

–      In Repeat and Combined modes, user needs to enter a text after the command is issued. Provision for entering this text while the command is given to the tool is not provided. For example, ‘om R 30 cat’ doesn’t generate ‘catcatcatcatcatcatcatcatcatcat’. Making this feature available can help users if they want to use Om for generating text data using automation with Repeat Mode.

–      Om doesn’t provide its user with facility of choosing if they want the data to be added to clipboard or they want to see it on the command prompt. Currently the tool performs both the operations.

Automation Outlook

Automation using Om can help the users in two ways:

–      Generating same combination of text data every time the same or similar text fields of an application need to be tested. This way the tester need not remember the combination of data that s/he used for testing a particular text field, moreover the test data is generated in a jiffy.

Just run the script created for generating the data, use Ctrl+V to paste it in the text field to be tested and start testing!

Steps for automation

===================

Create a batch file (say C:\Om.bat).

Edit the batch file and type in the command,

cmd.exe /k “c:\program files\om\om.exe” r <count> <option>.

count and option to be used according to the users requirement.

Save the file.

Run the script to generate the data.

–      Creating text files of a specified size. Say, we want to create a text file of 2000 bytes. Just generate a string of 2000 characters using Om, open Notepad, use Ctrl+V to paste the contents generated by the tool and save the notepad as a text file. Text file of desired size is now created!

Automation for this task can be achieved using an AutoIT Script.

Code for generating a text file (AutoIt Script)

=======================================

Run(“C:\Windows\notepad.exe”)

WinWaitActive(“Untitled – Notepad”) ; Open Notepad and wait for it to open

sleep(500)

Run(“C:\Program Files\Om\Om.exe” & ” r 2000 -lun”) ; Generate text data of 2000 ;characters

sleep(500)

Send(“^v”)  ; Ctrl+V paste the text data in notepad file

Send(“!f”)

sleep(500)

Send(“a”)

WinWaitActive(“Save As”)

sleep(500)

Send(“C:\Om.txt”) ; Saved the file as Om.txt n C:

Send(“{ENTER}”)

sleep(1000)

Send(“!{F4}”)  ; Closed the text file

Conclusion

In this article, the audiences understood what Om tool is, the modes with which it operates and the ways with which its options could be used to generate text data useful for random and field testing. The author suggests the readers to refer the article and get their hands dirty on this tool as soon as possible so that they can take advantages of the benefits provided by it.

References

  1. http://omfortesting.110mb.com/

By Sanket Vaidya

Referred on 30th October 2010.

  1. http://www.opensourcetesting.org/

Referred on 30th October 2010.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.