Much like every site on the internet, we use cookies to help analyze traffic and improve our website. As outlined in our privacy policy, any information is only used internally and is not shared with outside organizations.
Learn More

Most users of Test Design Studio are already familiar with the benefits you gain from incorporating VBScript Class objects into your code.  Using classes helps organize your code and improve comprehension.

In the next release of Test Design Studio 2, we’re making it even easier to add classes to your projects with a new ‘Class Definition Library’ template.  Item Templates are used to generate new content for your projects.  This powerful feature allows you to generate files with pre-defined content and are highly customizable to meet your individual needs (read more in the on-line documentation).

image

In the screenshot above, we have selected the ‘Class Definition Library’ template, and will name our file ‘Person.qfl’.  The class we are creating in this example will be to represent a ‘Person’ object, so we are naming the file to correspond to the class we are creating.  This name means more than just the name of the file, the template will use this name to generate the contents of the file as well.  Below is the generated template:

image

In the screenshot above, we have highlighted all the areas where the name of the file, “Person”, was used in the dynamic generation of the class code.  By naming the file the same as the desired class, we are able to quickly generate a lot of the code that you would normally have to manual type.

A quick tour of the base template code…

Lines 4 – 36 include the class declaration itself and corresponding comments.

Lines 12 – 20 provide the skeleton to insert any code that should be executed when the class is created or destroyed.

Lines 22 – 34 include “Region” markers for outlining support of Properties and Methods that you define with your class.  Note that the comments remind you to use the code snippet features of Test Design Studio to quickly generate the members of your class (read more about code snippets if you aren’t familiar with this time-saving feature).

Lines 39 – 46 include a public function to instantiate and return a new instance of your class and the corresponding documentation for the method.  Some versions of QuickTest Professional have a limitation where you cannot use the ‘New’ keyword to create instances of classes that are defined in external libraries, so this trick helps resolve that issue.  Note how the name of the class is used multiple times in this code block to produce the necessary function… great time-saver!

Now that you have a new class, you can easily make this class available to all the tests in your project by using the Build Process to programmatically update the library references for your tests.

While we’re happy to include this built-in template with the next release of Test Design Studio, there’s nothing to prevent you from creating your own templates right now.