You are on page 1of 12

SILK TEST 7.

5
Overview of Results Logging – Overview of Class Mapping

Jagan Mohan Julooru


Overview of results logging
In order to provide organizations wider access to test results, SilkTest includes a results
logging feature that can be used to establish an MS SQL database for logging test results
and log test information to that database during the running of tests.
In order to be able to log results, you must do the following:

1 Install the following two components of the Results Repository installer,


Results Logging which enables the computer to log results, and the Results
Repository which creates the database.
2 Configure the system properly.
3 Include LogResults.inc in the Use Files field in the Runtime Options dialog
(or the options set UseFiles, if using an existing option set).
4 To distinguish test run information, modify two constants in
ResultsRepository.inc for each test run.

Before using results logging


You may encounter some issues with results logging. Please read the following before
using results logging:
• Results logging and the recovery system
• Results logging and existing option sets

Results logging and the recovery system


If you have already written versions of the functions used by results logging (contained in
LogResults.inc) and they are either:
• Currently being compiled/run, or
• Mentioned in a use statement by files involved in a current compile/run, or
• Listed in your Use Files in the Runtime Options dialog

Jagan Mohan Julooru


you will get compilation errors because you have defined more than one version of one or
more of these functions. To resolve this problem see Resolving conflict between results
logging and recovery system.

Results logging and existing option sets


If a testplan uses an option set (via the optionset keyword) and that option set uses the
UseFiles option to override the Use Files defined in the in the Runtime Options dialog,
then logging is temporarily turned off if LogResults.inc is NOT included in the list of
UseFiles.

This will affect all tests run from the testplan at the level of the optionset keyword. Once
that level is complete, logging will be turned back on, unless another option set is
specified that also excludes LogResults.inc from the UseFiles.

Having logging turned off will mean no individual test data for those affected testcases
will be written to the database, and if logging is still off at the end of the run, no summary
data for the testplan will be written to the database.

Results Logging component


When you select to install the Results Logging component from the SilkTest Results
Repository Installer, SilkTest:

• Installs MSDE, if MDSE or SQL 7 is not already installed,


• Creates the required registry keys, and
• Enables the specified computer to connect with the results repository, by creating
an ODBC DSN.

Results Repository component


When you select to install the Results Repository component, SilkTest creates the
database and two tables, Runs table and Tests table, on the computer specified. The

Jagan Mohan Julooru


system data source, called SilkTestRepository, is created/updated on the computer
running the installer.

SilkTest Results Repository files


The Results Repository relies on two files:

• LogResults.inc - this file contains 4Test functions that enable logging to a


database. This file must be included in the Runtime Options Use Files (or in the
Option Sets UseFiles). This file calls SilkTestRepository.inc.
• SilkTestRepository.inc - This file contains customizable constants. The user
accesses this file to customize database information that allows the user to
distinguish the test run information of different versions of the application under
test. LogResults.inc calls this file.

Disabling results logging


To disable test results logging to the results database you need to remove the reference to
the LogResults.inc file. Do the following:

1 In SilkTest, click Options/Runtime to display the Runtime Options dialog.


2 In the Use Files text box select <SilkTest installation
directory>\Resultslogging\LogResults.inc. Press Delete.

Enabling results logging


In order to log test results, before you begin testing, do the following:

1 In SilkTest, click Options/Runtime to display the Runtime Options dialog.


2 Next to the Use Files text box, click Add.
3 Navigate to the Resultslogging folder in the <SilkTest installation directory>.
4 Select LogResults.inc, click Open.

Jagan Mohan Julooru


This LogResults.inc file contains 4Test functions that will enable logging into a results
database every time you run a testplan or script. The functions that are contained in
LogResults.inc are built on the recovery system capabilities inherent in SilkTest.
WARNING If you have customized the recovery system and make use of these functions,
enabling results logging could potentially conflict with the versions of these functions
you have in your testing environment.

Installing the results repository


Note You must have administrative privileges for the computer on which you want to
install the results repository.

A separate installer for the results repository is provided with SilkTest. The results
repository installer has three components:
• Results Logging: enables your computer to log test results
• Results Repository component: creates the SilkTest results repository (database
and tables).
• Results Viewer: configures an existing Microsoft Web server for the
demonstration HTML results viewer.

To install the SilkTest results repository:


1 Locate ResultsRepository.exe
• If you have a SilkTest CD: Insert the CD into the CD-ROM drive. Cancel the
Setup program if it starts automatically. Start the results repository manually by
selecting Start/Run and typing
<cddrive>:/ResultsRepository/ResultsRepository.exe.
• If you are downloading the results repository: Navigate to the SilkTest page of the
Segue download area.
2 Double-click ResultsRepository.exe, specify the location to which you want to
save the file, and then click Save.

Jagan Mohan Julooru


3 Navigate to the location in which you saved the ResultsRepository.exe, double
click ResultsRepository.exe.
4 Review the Welcome dialog, and then click Next.
5 Select the components you want to install, click Next. The HTML Results Viewer
is for demonstration only; it is not supported. For more information, see Results Viewer.
6 If the Results Repository installer does not find an existing ODBC compliant
database management system installed, you are prompted to specify the name of the host
computer to be associated with the data source.

The host computer must satisfy the configuration requirements of a Results Repository.
7 If you choose to create the SilkTest results repository, the installer prompts you to
specify the name of the computer on which to create the database and tables. The installer
then creates/updates a system data source, called SilkTestRepository, on the computer
running the installer. The data source will be associated with the computer where the
database and tables are created.
8 On the InstallShield Wizard Complete dialog, click Finish to exit the InstallShield
Wizard.

Resolving conflict between results logging and recovery system


You may encounter a conflict with the recovery system if you are already using the
functions contained in LogResults.inc, since they are used by results logging. To resolve
this, you have two options:

1 Rename your existing function and then call it from the appropriate function
within LogResults.inc. For example:
• CompanyOverrides.inc contains an existing use of the TestCaseExit function.
Rename the existing function CompanyTestCaseExit (Boolean bException).
• Then, in LogResults.inc, modify TestCaseExit (Boolean bException) to call
CompanyTestCaseExit as appropriate.

Jagan Mohan Julooru


• Copy and paste the statement(s) of your existing function into the equivalently
named function in LogResults.inc. Then comment out the existing function in the
file in which you originally created it. For example:
• CompanyOverrides.inc contains an existing use of the TestCaseExit function.
Copy the statement from the existing function TestCaseExit (Boolean
bException).
• Then, in LogResults.inc, modify TestCaseExit (Boolean bException) to include
the statement from the TestCaseExit function used in CompanyOverrides.inc.
• Finally, in CompanyOverrides.inc, comment out the function TestCaseExit.
• REMEMBER If you later disable results logging you will need to either:
• Rename your original versions back to TestPlanEnter/Exit, ScriptEnter/Exit and
TestCaseExit, if you renamed them and called the from LogResults.inc; or
• Uncomment the functions in the file(s) where you originally created them.

Using results logging with existing option sets


In order to use results logging with existing option sets you must add LogResults.inc to
the UseFiles in the options sets that you will be using. To do this:

1 In order to edit an option set you must first close it. In SilkTest, select
Options/Close Options Set, if necessary.
2 Select File/Open, navigate to the option set you wan to edit, and click Open.
3 In the .opt file, scroll to UseFiles. If necessary, click Edit/Find, type UseFiles
in the Find What text box, and click Find Next.
4 Type the path and file name, <SilkTest installation
directory>\Resultslogging\LogResults.inc, in the UseFiles. Be sure to place
this file before the SilkTest defined include files (for example
extend\explorer.inc) and use a comma to separate.
5 Save the option set. Click File/Save.

Jagan Mohan Julooru


To turn off results logging when using option sets you need to remove LogResults.inc
from the UseFiles in the option set. To do this:
1 In SilkTest, select Options/Close Options Set, if necessary.
2 Select File/Open, navigate to the option set you want to edit, and click Open.
3 In the .opt file, scroll to UseFiles. If necessary, click Edit/Find, type UseFiles
in the Find What text box, and click Find Next.
4 Delete the path and file name, <SilkTest installation
directory>\Resultslogging\LogResults.inc, from the UseFiles.
5 Save the options set. Click File/Save.

If the option set is not used by a large number of testplans, you may want to create a copy
of the existing option set and then add the LogResults.inc file to the UseFiles in the copy.
Rename the copied option set with a name that distinguishes it from the original as one
that logs results. In taking this approach, you will only need to re-specify the .opt file
used by the optionset keyword in the test plan.

Why SilkTest sees objects as custom windows


An object is defined by:
• Its actual class name
• The underlying software code that creates and manipulates it
SilkTest defines an object (window or control) as a CustomWin whenever either or both
of these definitions vary from what is considered to be standard. While you record
window declarations, SilkTest attempts to identify the class of each object in your GUI
and assign the appropriate class from the built-in class hierarchy. If an object does not
correspond to one of the built-in classes, SilkTest designates the object as a custom
window and assigns it to the class CustomWin.

For example, SilkTest supports the standard MFC library, which is a library of functions
that allow for the creation of objects and the mechanism of interaction with them. In
supporting these libraries, SilkTest contains algorithms to interrogate the objects based

Jagan Mohan Julooru


upon the standard libraries. When these algorithms do not work, SilkTest reports the
object as a CustomWin.
Let’s say that you see a text box in a window in your application under test. It looks like a
normal text field, but SilkTest calls it an object of the class CustomWin.

Two reasons why SilkTest sees the object as CustomWin


There are two reasons why SilkTest sees the object as a CustomWin.
• Upon its definition in the application under test, the control was simply named
differently than the standard name. For example, instead of it being named a
TextField, it was named EnterTextRegion. If this is the only reason, then you can
class map the control to the standard name.
• You never know whether class mapping will work until you try it. It will work if
the object isn’t really a custom object, but rather a standard control with a non-
standard name. Try this as your first attempt at dealing with a CustomWin.

If the class mapping does not work, it is because of the following reason.
• The object truly is a custom object; that is, the software in the application under
test that creates and manipulates the object is not from the standard library. That
means that the SilkTest algorithms written to interrogate this kind of object will
not work, and other approaches will have to be used to manipulate the object.

How you support custom objects depends on whether the object is a graphical control,
such as a tool bar, or whether it is not a graphical control, such as a text box.

SilkTest does not recognize the class of the object


While using the Record Window Declarations dialog, you will on occasion notice that the
recorded class is CustomWin, indicating that SilkTest does not recognize the class of the
object. The object is interpreted as a custom object. Custom objects often look and act the
same as their corresponding known, standard objects and they may correspond to built-in,
known classes

Jagan Mohan Julooru


If the object is in fact a custom object, to be able to record and run testcases that interact
with the custom object, see Mapping custom classes to standard classes.

However, if the object is not actually a custom object, but is instead a standard object that
your application’s developers have renamed, you can record and run testcases merely by
establishing a class map between the renamed class and the standard 4Test class. You can
also filter out unneeded custom classes can be filtered from the class hierarchy.
Class mapping only works for objects that are created with standard API calls but are
given non-standard names.

Using class mapping to filter custom classes


You can use 4Test to filter out unnecessary classes, such as invisible containers. Ignoring
these unnecessary classes simplifies the object hierarchy and shortens the length of the
lines of code in your test scripts and functions. Container classes or ‘
frames’ are common in GUI development, but may not be necessary for testing.
You tell SilkTest to ignore instances of a container class via the Class Map dialog. When
you tell SilkTest to ignore these classes, the classes are not recorded.

After filtering out a custom container class you may occasionally lose the ability to see its
child objects. In the above example, all the dialog objects (which are children of the
custom TBFrame class) might be no longer visible to 4Test.

You can also map a class to LookUnder to look ‘through’ the class, seeing the objects
under it. For example, there is a BlackFrame class in Visual Basic that is a 3-D black
border around controls. LookUnder is not in the standard classes list, so if you want to
use it you must type it in.

You can use class mapping to filter out:


• Object layers to ignore non-logical windows

Jagan Mohan Julooru


• Extra or "invisible" window layers in the object hierarchy
• An overlaying window that obstructs an object under it

About style-bits
Classes may allow different styles of instantiation. Style-bits determine the styles that can
be applied to an object. For example, a PushButton, CheckBox, and RadioButton are all
variants of the native Windows Button class. They are all the same class, but each has
different style-bit to determine the specific look and behavior of the button.

You can map not only an entire class, but also specific ‘styles’ of one class to another,
known class.

Class mapping with style-bits


1 In the Custom Class field of the Class Map dialog, enter the class name, style-bit,
and style-mask. The style-mask tells SilkTest which parts of the style-bit to use. As a
general rule, simply repeat the style-bit.
2 In the Standard Class field, enter the known class. This can be any standard 4Test
class or a user-defined class.
3 Click Add and then click OK.

Notes
The style-mask may also take the format: 0xFFFFFFFF, where ‘F’ includes the bit and
‘0’ turns it off. For example, one custom PageList may look like 0x12345678 and
another of the same type may look like 0x12345679. You could class map it like:

newpageclass,0x12345678,0x12345678=PageList
newpageclass,0x12345679,0x12345679=PageList
And on and on for each one like it, or…
newpageclass,0x12345678,0xFFFFFFF0=PageList

Jagan Mohan Julooru


What this says is that every instance of newpageclass 0x1234567? should be class
mapped to PageList. The last bit, being turned off, is ignored.

Mapping a custom class


When a declaration for a CustomWin appears in the Record Window Declarations dialog:

1 Press Ctrl+Alt. The declarations are frozen in the Window Declaration list box in
the lower half of the Record Window Declarations dialog.
2 In the Window Declarations list box, click on the line containing the declaration
for the custom object. The line is highlighted and the declaration for the CustomWin
appears in the Window Detail group box.
3 In the Window Detail group box, click Class Map. The Class Map dialog appears.
The name of the custom class is displayed in the Custom Class text field.
4 In the Standard Class field, enter the name of the built-in 4Test class to which you
are mapping the custom class.
5 Click Add. SilkTest adds the class name.
6 Click OK.

When you resume recording, the object has the standard 4Test class. If SilkTest
encounters a similar object, it automatically maps the object to the correct 4Test classes.
You must modify any prerecorded declarations containing these objects to use the
standard class.

Jagan Mohan Julooru

You might also like