Login   /   Register
Code Techniques

Class inheritance in VBScript – Now at your doorstep!

October 4th, 2008 by Yaron Assa
     6 votes, average: 4 out of 56 votes, average: 4 out of 56 votes, average: 4 out of 56 votes, average: 4 out of 56 votes, average: 4 out of 5
Loading ... Loading ...

VBScript’s lack of class inheritance can be quite problematic for those of us who are using Classes regularly throughout our scripts. The attached file provides a parser which enables you to effectively use class inheritance in VBScript by placeing ‘ ParentClassName comments within your classes. The mechanism will:

1. Enable inheritance from multiple parents (just use multiple lines with Inherit comments)
2. Copies Properties, Variables, Functions and methods from the parent class to the derived class.
3. In case the derived class already has a code segment with the same name, the copied code-segment is changed to MyBase_. Inner segment placements are updated accordingly.
4. Enables inheritance through multiple hierarchies (e.g. GrandParent->Parent->Child inheritance). Circular inheritance protection. The order of appearance in the files is irrelevant, the parser will make sure the parent classes are parsed before their derived classes.
5. The parser has a major downside – as the technique uses ExecuteGlobal to load the processed classes into QTP, you cannot debug the code in mid-run.

An improved dictionary object

June 19th, 2008 by Yaron Assa
     4 votes, average: 4.75 out of 54 votes, average: 4.75 out of 54 votes, average: 4.75 out of 54 votes, average: 4.75 out of 54 votes, average: 4.75 out of 5
Loading ... Loading ...

This article will offer an improved version of the native Scripting.Dictionary object, and provide a step-by-step guid for building it.

Class Composition

March 29th, 2008 by Yaron Assa
     5 votes, average: 4 out of 55 votes, average: 4 out of 55 votes, average: 4 out of 55 votes, average: 4 out of 55 votes, average: 4 out of 5
Loading ... Loading ...

This article deals with classes and their instances in VBScript. Make sure you’re familiar with the subject by reading the introduction article to classes.

In this article we’ll cover the basics for composing classes (i.e. using one class from within another), and some common and less common uses for this technique. I’m sure that once you’ll see the huge benefits we can gain by selectively using this technique, you’ll at least try it.

Introduction to classes

March 29th, 2008 by Yaron Assa
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

This article will very briefly cover the subject of VBScript classes. My purpose is not to do a detailed sweep, but only a quick reminder in order to move forward to more advanced topics and techniques in articles to come. You can find detailed information and demos on this subject in the book Scripting Quicktest […]

Factory Pattern

March 29th, 2008 by Yaron Assa
     1 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 5
Loading ... Loading ...

This article refers to design patterns, pointers and objects (discussed in the background section of this article), and classes. Make sure you’re familiar with these issues before reading on. It would also be prudent to brush up on the Singleton Pattern.
We continue our tour of Design Patterns with another basic pattern – the Factory (or […]

Singleton Pattern

March 29th, 2008 by Yaron Assa
     1 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 5
Loading ... Loading ...

This article refers to design patterns, pointers and objects (discussed in the background section of this article), and classes. Make sure you’re familiar with these issues before reading on.
We begin our exploration of the word of Design Patterns with one of the simplest patterns – the Singleton. The Gang of Four eloquently summarize the intent […]

Introduction to design patterns

March 29th, 2008 by Yaron Assa
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...

This section relays heavily on your familiarity with basic code design concepts and approach. Make sure you read the introduction to code design before proceeding.
Parts of the following introduction are rewrites (more accurately downgrades) of the preface to the groundbreaking book Design Patterns: Elements of Reusable Object-Oriented Software, written by the “Gang of four”. If […]

Checkpoints and points-of-view

March 29th, 2008 by Yaron Assa
     4 votes, average: 3.25 out of 54 votes, average: 3.25 out of 54 votes, average: 3.25 out of 54 votes, average: 3.25 out of 54 votes, average: 3.25 out of 5
Loading ... Loading ...

Many of QTP’s downsides are due to the inherent tension between trying to be beginner-friendly, to having enough depth and complexity for writing real automation scripts. It’s more than just having too many menus and options – in some cases; QTP induces shallow thinking and bad habits. I apologize for being dramatic, but in my […]

Abstraction Leaks

March 29th, 2008 by Yaron Assa
     1 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 5
Loading ... Loading ...

Abstractions
Abstractions are the cornerstone of any successful program. An abstraction is a blackbox, wrapped around some very complex real-world mechanism. This magical blackbox allows us to use it, without dealing with the actual complexity that goes on inside.
For example, characters are abstractions: There is no character data type in the real world, since characters are […]

Negative Tests

March 29th, 2008 by Yaron Assa
     3 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 5
Loading ... Loading ...

Background & Motivation
Negative tests are a crucial part of application testing – they ensure us the application contains “bad” user behavior and illegal inputs in a controlled fashion. Having said that, usually there’s never enough time, resources and personal to automate the “positive” tests; let alone the negative ones. This is not an inevitable situation […]

Object Dictionaries for generic functions

March 29th, 2008 by Yaron Assa
     2 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 5
Loading ... Loading ...

Today we’ll cover a valuable technique that will enable us to greatly simplify and organize our code, by adding meta-data to our QTP objects. The technique is best used when coupled with DP, though with certain adjustments, it works fine with OR based scripts as well.
The content you are accessing is for registered users onlyRegisteration […]

Introduction to Code Design

March 29th, 2008 by Yaron Assa
     2 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 5
Loading ... Loading ...

This will be the first of many articles dealing with code design. What is code design? In object oriented languages it sometimes stands for deciding on the object class and structures needed to elegantly complete a task. For us it will just be a set of abstract principles that will allow us to write readable, […]

Optional Parameters

March 29th, 2008 by Yaron Assa
     3 votes, average: 2.33 out of 53 votes, average: 2.33 out of 53 votes, average: 2.33 out of 53 votes, average: 2.33 out of 53 votes, average: 2.33 out of 5
Loading ... Loading ...

Sadly, QTP uses VBScript (natively at least). This means that in order to build effective QTP tests, we need to master VBScript syntax; as well as tips and tricks that could help us around its shortcomings.
The Problem
One of the bugging issues with VBScript is it doesn’t handle function growth and extensibility over time. Specifically, VBScript […]

Multiple exist gates

March 29th, 2008 by Yaron Assa
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

It’s very easy to control the entry gate to an action or function - there’s only one way to enter them. However, the number of exit gates can vary widely from 1 to many according to the inner logic of the action/function. Today I’m going to address managing multiple exit gates in actions and functions.
When […]

Implementing a Stack using a dictionary

March 29th, 2008 by Yaron Assa
     2 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 5
Loading ... Loading ...

In computer science, a stack is a temporary abstract data type and data structure based on the principle of Last In First Out (LIFO). Stacks are used extensively at every level of a modern computer system. For example, a modern PC uses stacks at the architecture level, which are used in the basic design of […]

Implementing a Queue Using a Dictionary

March 29th, 2008 by Yaron Assa
     3 votes, average: 3.67 out of 53 votes, average: 3.67 out of 53 votes, average: 3.67 out of 53 votes, average: 3.67 out of 53 votes, average: 3.67 out of 5
Loading ... Loading ...

A Queue is a particular type of collection containing entities that are kept in order. The principal (or only) operations on the collection are the addition of entities to the last position and removal of entities from the first position. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the […]

About this section

March 28th, 2008 by Yaron Assa
     3 votes, average: 3 out of 53 votes, average: 3 out of 53 votes, average: 3 out of 53 votes, average: 3 out of 53 votes, average: 3 out of 5
Loading ... Loading ...

This section will cover several general methods and techniques that are needed for advanced QTP usages. These will vary from VBScript coding tips and QTP object-recognition methods, to object-oriented design patterns.
This section is meant to be more abstract and general than specific environment techniques and workarounds, but in my opinion it can make a […]

Function Pointers in VBScript

October 22nd, 2007 by Meir Bar-Tal
     6 votes, average: 4.83 out of 56 votes, average: 4.83 out of 56 votes, average: 4.83 out of 56 votes, average: 4.83 out of 56 votes, average: 4.83 out of 5
Loading ... Loading ...

This 14-page article by Meir Bar-Tal explains in details the benefits and inherent possibilities in wrapping our functions with classes. It further explores the meaning and logical structure of classes, and shows how we can easily implement constructors, event handlers and callback by using class composition and function wrapping.
The different techniques are well illustrated […]