Friday, June 30, 2006

More about Object Repository Files [ADVANCED]

To be able to mimic what was done by a user, QTP learns the object the user interacts with by recording enough properties of the object to be able to uniquely identify the object. This, as you know, in QTP is the object repository. The object repository is simply a file that has to be stored on the system. QTP uses two file types for doing this. A TSR file and and MTR file.

TSR file
This is the file type QTP uses to store an object repository when you choose 'Shared' mode in Test->Settings->Resources. The TSR file must then be referenced by any test that wants to use the objects within that repository.
What we do is learn all the objects within an application and store it inside a single file, therefore anytime you want to test that object, you simply have to load the correct TSR file.

How to create a TSR file
There are two forms for doing this.
1. Create a new test, open the Object Repository by clicking Tools->Object Repository. From the tools use 'Add New Object' to add the objects you want. Then click 'Export' and choose a filename.tsr to save the object repository as.
2. Create a new test, open the Resources tab at Test->Settings->Resources. Type in the name of the tsr file you want to create. It will prompt you that you are creating a new file, say yes. Open the Object Repository by clicking Tools->Object Repository. From the tools use 'Add New Object' to add the objects you want. Then click 'Save'.
Note: In 1, you export, in 2, you save

MTR file
A second, but much lesser used for is the 'Per Action' object repository. In this form, you do not worry at all about your object repository. Sounds too good to be true, and it is. The problem with this form is that if anything changes in the application, you have to go back and re-record ALL the actions that use the changed object. This form is almost only used when testing a mature application, i.e. one in which you know (with great certainty) that the GUI objects will not change.

Tuesday, June 20, 2006

Test Planning (draft)

The following document identifies some useful steps an process that must be implemented during the test planning phase.

Identify System environment
- Networks: What network type are you using, WAN, LAN, VPN? What are the limitations?
- Platforms: What operating systems does the AUT support. Can it only work on certain versions of an OS e.g Windows 2000 but not Windows 98 etc
- Languages: What human languages does the application support. Just English? Or more?

Define your Testing Environment

- Database server: What databases are in use in the AUT?
- Database structure: Identify your database schema that will be used to retrieve data from the database.
- Database access: What are the available usernames for each database instance? What is your database downtime schedule to avoid scheduling tests at those times?

Management Priorities
- What are you testing for? Performance? Functionality? Backward compatibility?
- What is the proposed release date of the application?

Testing resources
- PCs available
- Time
- Skills testers have
- Determine what and how you want to test

Identify the risks
- Failures that cause the most damage

Prioritize the testing tasks
- Which application modules will be tested first

Define test subjects
- Divide your application into modules or functions
- Build a test plan tree

Define tests
- Step- Description- Expected Results

Design test steps
- Break down each step; points you want to check

Testing Concepts

Logical Name Mapping
This is the conception of describing the objects in the application into a relevant source file and assigning this object a logical name. The logical name is an alias you will use in your script to refer to this object during test execution. It is best when logical names and short, simple and descriptive of the objects they represent. The process with which logical names are captured vary by the automated tool in use.


Data Parameterization
parameterization is used in testing to make test scripts easily configurable. When tests are recorded, the values entered into the test are literal values. Often times, to provide some variance of execution for the test it is necessary to modify the values used in the test.

Checkpoints
Checkpoints are used to ensure that when execution gets to a specific point during the execution of an application. The value found in the application, (or related resource eg database, XML etc) is the value expected at that point. As an example, if you log into your Yahoo account, you will expect to find mail address to you.

Output values
These provide a way for a testing tool to retrieve values from within an application being executed. Output values return specific information from the AUT or related resource such as a database to the application.

Synchronization
This is used whenever events take an indefinite period of time to complete. Synchronization is simply a mechanism used to tell the testing tool to wait for a signal before continuing its operation. Alternately you can specify a maximum amount of time you are willing to wait for the previous operation to complete before you mark the test as failed.


Scripting
All automated testing tools support the use of a script language. In fact,when you record the steps you perform, they simply translate this into the script language that is supported by the tool. Luckily, it is easy to pick up script languages and we can use the logic within these powerful tools to increase the power of our testing tool.

Thursday, June 15, 2006

QTP Steps

This document is created to provide a simple guide on steps for performing certain operations in QTP, this does not provide a discussion of 'why', it simply shows 'how'


CREATING AN OBJECT REPOSITORY


[Method 1]
1. Open a new test
2. Open the object repository by clicking 'Tools->Object Repository'
3. Click the 'Add New Object' button
4. Click the object in your application that you want to introduce into the object repository
[Repeat 4 for all the objects you want to store. Note that by clicking on the header of a container, QTP can learn all the objects in the window]
5. Click the 'Export' button
6. Type in the name of a file in the dialog window that appears
[This will save a file on your harddrive with a TSR extension. This is your shared object repository]


[Method 2]
1. Open a new test
2. Open the Resources tab by clicking 'Test->Settings->Resources'
3. Specify 'shared' as the object repository type.
4. Type in the name you want to give your object repository in the available field
[You must specify a filename that does not exist, and you must include the .tsr extension]
5. Close this window by clicking OK
6. Open the object repository by clicking 'Tools->Object Repository'
7. Click the 'Add New Object' button
8. Click the object in your application that you want to introduce into the object repository
[Repeat 8 for all the objects you want to store. Note that by clicking on the header of a container, QTP can learn all the objects in the window]
9. Click the 'Save' button



USING AN OBJECT REPOSITORY FILE

Before you begin, you must know the following
a. The location, and name of your object repository file.

1. Open a new test
2. Open the Resources tab by clicking 'Test->Settings->Resources'
3. Specify 'shared' as the object repository type.
4. Click the ellipsis to bring up the 'File Open' dialog. Search for your object repository file. Choose it, and click okay.
[IMPORTANT: Choose the file instead of typing in the name, this will ensure that you select a file name that already exists]
5. Close this window by clicking OK
6. Start recording, editing...




CREATING AN ODBC DATASOURCE

Before you begin, you must know the following
a. The type of datasource you want File, System or User
b. The type of database that you want to connect to
c. The connection details for connecting to the database

[Microsoft Access]
1. Bring up the system's Control Panel
2. Choose 'Administrative Tools->Data Sources (ODBC)'
3. Choose File, System or User DSN tab
4. Click the 'Add' button
5. Choose the appropriate driver for the database you have in mind
[For Access, this would be Microsoft Access Drive (*.mdb)]
6. Click Next
7. In the DataSource dialog, do the following
Type in the DatasourceName
Click Select and choose the file from the file system,
Optionally type in a description
Click Finish to dismiss this dialog
[You will now see the DSN in the list of DSNs on the machine]
8. Clicking Ok to close the ODBC tool.



Specify Object Repository
-----------
1. Open a new test [File->New->Test]
2. Open the Test Settings dialog [Test->Settings->Resources]
3. Select shared
4. Click on the ellipsis
5. Choose your object repository [.tsr] from the file system


Checkpoints
-----------
1. Begin Recording [Test->Record]
2. Select Checkpoint [Insert->Checkpoint]
3. Select Object
4. Specify Checkpoint details
5. Stop Recording [Test->Stop]


Output Value
-----------
1. Begin Recording [Test->Record]
2. Select Output Value [Insert->Output Value]
3. Select Object
4. Specify Output Value details
5. Specify DatatTable column
6. Stop Recording [Test->Stop]


Data Parameterization
---------------------
1. Open the Data Driver Wizard [Tools->Data Driver]
2. Click on the item to parameterize
3. Click the Parametrize button
4. Choose step-by-step parameterization
5. Click Next
6. Click the Modify Parameters icon if you want to change the data table column. Type in the Name, click Ok.
7. Click Finish
8. Repeat steps 2 to 7 for each value you want to parameterize.


Synchronization Point
---------------------
1. Select Synchronization Point [Insert->Output Value]
2. Select Object
3. Specify Synchronization Point details
[Details include:
object: The object you are waiting for
Property: The specific property of this object that you are waiting for
Value: The value you expect the property to get
Timeout: The maximum amount of time your are willing wait for the event to occur
]

Wednesday, June 07, 2006

VBScript [draft]

What is VBScript?
Originally conceived as a web scripting language to provide some client-side validation and programmatic functionality to HTML pages (similar to JavaScript), VBScript has grown to become the scripting language of choice in many tools such as Mercury Interactive's QTP and Microsoft's Monad Shell.
By being a script language, VBScript is incredibly lightweight containing only a small number of keywords and operators, yet being able to support useful functionality.


HISTORY
=======
VBScript is related to the Visual Basic family of languages and bears a lot of syntactic similarities to the language. However, by being a script language, VBScript supports much less functionality than Visual Basic or Visual Basic.Net.


LANGUAGE CHARACTERISTICS
========================
Syntax - VBScript has English-like syntax reminiscent of such languages as COBOL, FORTRAN etc. This sets it apart from languages derived from C/C++ that have a heavy reliance on symbols.

Supports COM Objects - COM objects can be instanced and referenced from within VBScript giving the language considerable strength of functionality.
[Note: COM objects cannot be created in VBScript. ]

Interpreted - VBScript is an interpreted language requiring that the source code for the script be made available to the interpreter at runtime.


LANGUAGE CONTENT
=================
Comments - Used to explain code sections
Variables - Temporary storage for data
Constants - Permanent storage for data
Declaration - Reservation of space for a variable or constant
Naming Rules - The following 5 rules that must be followed to name items
1. Must begin with letter or underscore
2. Can't contain special characters except underscore
3. Can't be same as the keyword
4. Must be less than 255 characters long
5. Must be unique

Operators
* Arithmetic - Operators used for mathematical computation
* Relational - Use to compare 2 values against each other
* Logical - Used to simplify one or more boolean conditions
* Assignment - Used to store the value of an expression
* Concatenation - Uses to combine strings

Control Flow
* Branching - Allows sections of code to be skipped
+ If - Allows branching based on a set condition
+ Select - Allows branching based on the value of a variable
* Loops - Allows section of code to be repeated
+ While - Entry condition loop
+ Do...While - Exit condition loop
+ For - Iterated Loop
Functions
* Built-In - Code units provided with the VBScript language
* User Defined


OPERATORS
=========
Arithmetic
- Subtraction
+ Addition
/ Division
* Multiplication
^ Exponent
Mod Modulo

Relational
> Greater than
<>= Greater than or equal
<= Less than or equal = Equals <> Not equal

Logical
And
Or
Not

Assignment
= Assign

Concatenation
& Concatenate


KEYWORDS
========
Comments - ', Rem
Declaration - Dim, Const
If - If, Then, Else, ElseIf, End If
Select - Select, Case, Else, End Select
While - While, Wend
Do...While - Do, Loop, While
For - For, To, Step, Next, Exit
Function - Function, Sub, Byval, ByRef, Exit, End Function
Misc - Option Explicit, Option Compare Text, Option Compare Binary

USEFUL FUNCTIONS
================
Msgbox - Displays information
InputBox - Allows the application to accept input
Now - Returns the system date and time

Friday, June 02, 2006

What is ODBC?

Why ODBC?

The concept of ODBC is important for database connectivity because it provides a mechanism in which the developer can insulate themselves from the inherent difficulties in learning how to connect to every possible type of database that exists. Using ODBC, the developer simply connects to an ODBC datasource and lets the ODBC connection specify the database it wants to connect to.

Still unclear? Well lets take a second look at the process of an application connecting to the database. As shown in Figure 1, the developers writes code to connect to a specific database, if connection details about a database changes, the use of a configuration file will make it easy for the application to adapt to the change.


------- --------


APP ---> DB

------- --------

V
--------
config
file
-------


Figure 1: Direct connection to a database using settings from a configuration file

What happens when the actual type of database changes? Well, this is more complicated because the connection details of different databases expectedly are different. MS Access, for example is a file based database and as such would require you to specify the Access database file from your filesystem. Oracle, which is a connection based database will include such details as the host, port, username and password that will be used to connect to the database. Unless a large amount of code has been written to support all possible types of databases that an application can encounter, the application will no longer be able to connect to a database. In technical parlance, your application now has a vendor dependency. If you start out with Oracle, and Oracle were to raise their rates tomorrow, you'd have no choice but to pay it. But, another way exists and that is ODBC.
ODBC leaves the task of database configuration to the user, or an installer, and allows the developer to worry about connecting with the ODBC datasource. This way, during runtime, a user can change the connection details about their applications easily (Just as can be done in the previous example), but they can also change the type of database being connect to. Figure 2 shows the chart of a database that is being connect to through the use of an ODBC datasource.


------- -------- ----------------

SQL Server DB
APP ---> ODBC ---->---------------
Oracle DB
------- -------- ----------------

Figure 2: Indirect connection to a database using ODBC

As long as the data in the database internal structures (tables, fields, relationships etc) remains the same, the application will be able to continue using the database.

You will find that this technology works out perfectly for any automated testing tool. It is impossible for the developers of QTP to know the type of database you will use in you applications. In fact, it is possible for your application to be using a DBMS that was created after QTP was released. So how can QTP connect to it, well, using ODBC, QTP simply must know how to connect to a datasource defined on your computer. The tester will then complete the connection by connecting the datasource to the actual database that is used in you application.

This means that to use ODBC during your testing, you will need to create an ODBC data source. We will go through the process of creating thus, but before we begin we must discuss some items that you will need. When dealing with ODBC, you need to know at least three details, including:

Data Source Name - A unique data source name (DSN) that you will use to refer to your database on the machine. Think of the DSN as an alias for the database. While the DSN can really be anything, it is often best to specify a name that bears some relation to the real database, or the AUT.

CAUTION: Don't forget that you must create the same DSN on all machines you intend to run your test on. Without doing so, your test will not have a valid connection to the database and as such, will fail.

Data Source Type - The type of data source which you intend to create. There are two major types
* Machine Datsource
* File Datasource

Database Driver installed - You can only create an ODBC data source for a database that has the appropriate drivers installed on your system. You can easily check the list of drivers you have installed by clicking on the Drivers tab of the ODBC dialog.

You will find that the choice of drivers chosen determines the type of details that will be requested from you during the process of adding your datasource. Access, for instance being a file based database provides a button that allows you to select the database file from the filesystem while SQL Server, a connection based database, request such details as the host on which the database is running. Expectedly, you cannot conclude the creation of an ODBC data source if you do not have all the necessary details.