silktest 13 - micro focus supportline ?· 2012-05-25 · silktest 13.0 silktest classic: testing...

Download SilkTest 13 - Micro Focus Supportline ?· 2012-05-25 · SilkTest 13.0 SilkTest Classic: Testing Java…

Post on 14-Jun-2018

215 views

Category:

Documents

2 download

Embed Size (px)

TRANSCRIPT

  • SilkTest 13.0

    SilkTest Classic:Testing Java

    Applications withthe Classic Agent

  • Micro Focus 575 Anton Blvd., Suite 510Costa Mesa, CA 92626

    Copyright 2012 Micro Focus. All rights reserved. Portions Copyright 1992-2009 BorlandSoftware Corporation (a Micro Focus company).

    MICRO FOCUS, the Micro Focus logo, and Micro Focus product names are trademarks orregistered trademarks of Micro Focus IP Development Limited or its subsidiaries or affiliatedcompanies in the United States, United Kingdom, and other countries.

    BORLAND, the Borland logo, and Borland product names are trademarks or registeredtrademarks of Borland Software Corporation or its subsidiaries or affiliated companies in theUnited States, United Kingdom, and other countries.

    All other marks are the property of their respective owners.

    2012-05-07

    ii

  • Contents

    Introduction ........................................................................................................ 4Updating the Java Reference of the Sample Java Applications ......................................... 4

    Java AWT Tutorial .............................................................................................. 5Step 1: Enabling Java Support in the Basic Workflow Bar ..................................................5Step 2: Becoming Familiar with the Sample Java AWT Application ................................... 5Step 3: Focusing On a Part Of the Sample Java AWT Application .....................................6Step 4: Identifying Custom Controls in the Drawing Area Window ..................................... 6Step 5: Recording a Class for the Drawing Area Canvas ................................................... 6Step 6: Recording Window Declarations for the Drawing Area ...........................................7Step 7: Preparing the Test Script File ................................................................................. 8Step 8: Recording a Test Against Drawing Area Controls .................................................. 8Step 9: Running the Recorded Test Against the Sample Java AWT Application ............... 9Step 10: Extending the Test Programmatically ................................................................... 9Step 11: Running the Extended Test ................................................................................ 10

    Java JFC/Swing Tutorial ..................................................................................11Step 1: Enabling Java Support in the Basic Workflow Bar ................................................11Step 2: Becoming Familiar with the Sample JFC Test Application ................................... 11Step 3: Focusing On a Part of the Sample Java JFC Application .....................................12Step 4: Recording Window Declarations for the Page List Window ..................................12Step 5: Preparing the Test Script File (JFC) ..................................................................... 13Step 6: Recording a Test Against Page List Controls ....................................................... 13Step 7: Running the Recorded Test Against the JFC Test Application .............................14Step 8: Getting Native Methods for a Predefined Swing Class .........................................14Step 9: Recording New Window Declarations for the Page List Window ......................... 15Step 10: Creating a New Test Using a Native Method ......................................................15Step 11: Running the Test that Uses Native Methods ...................................................... 16

    Contents | 3

  • IntroductionThe tutorials included in this document are designed to introduce you to using SilkTest Classic and theClassic Agent to test stand-alone Java applications developed with the Abstract Window Toolkit (AWT) andthe Java Foundation Class (JFC). The tutorials use the following sample Java applications:

    AWT Test Application JFC Test Application

    Download and install the sample applications from http://supportline.microfocus.com/websync/SilkTest.aspx. After you have installed the sample applications, click Start > Programs > Silk > SilkTest > Sample Applications and select the Java application that you want to use.

    Updating the Java Reference of the Sample JavaApplications

    SilkTest Classic no longer supports JRE 1.2. In order to run theSilkTest Classic sample Java applications,you may need to update the Java reference in the .bat file that launches each sample application. If youdo not have a local java.exe, you can download one from http://www.oracle.com/technetwork/java/index.html.

    To update the Java references:

    1. Use Windows Explorer to navigate to Programs > Silk > SilkTest > Sample Applications > Java AWT > Classic Agent> AWT Test Application.

    5. Use Windows Explorer to navigate to Programs > Silk > SilkTest > Sample Applications > Java AWT > Classic Agent> JFC Test Application.

    4 | Introduction

    http://supportline.microfocus.com/websync/SilkTest.aspxhttp://supportline.microfocus.com/websync/SilkTest.aspxhttp://www.oracle.com/technetwork/java/index.htmlhttp://www.oracle.com/technetwork/java/index.html

  • Java AWT TutorialThis tutorial is designed to help you get comfortable with testing a sample stand-alone Java applicationdeveloped with AWT controls, using Java support in SilkTest Classic.

    While working through this tutorial, you will perform the following tasks:

    1. Set up for testing the application.2. Become familiar with the sample Java AWT application.3. Focus on a part of the application under test (AUT).4. Identify custom controls and learn when to record classes.5. Record classes for custom Java controls.6. Record window declarations for all controls that you want to test.7. Prepare the test script file.8. Record a test against the Java application.9. Run the recorded test.10.Extend the test programmatically.11.Run the extended test.

    Before you begin this tutorial, learn the basics of recording test cases, running test cases, and using therecovery system. You can access the SilkTest Classic tutorials by clicking Start > Programs > Silk >SilkTest > Documentation > SilkTest Classic > Tutorials or by clicking HelpTutorials in SilkTestClassic.

    Step 1: Enabling Java Support in the Basic Workflow BarWhen you enable extensions in the Basic Workflow bar, Java support is configured automatically.

    To run the AWT test application:

    1. Install the applicable version JDK, if necessary.2. If you have not done so already, update the Java reference.

    For additional information, see Updating the Java Reference of the Sample Java Applications.

    3. Click Start > Programs > Silk > SilkTest > Sample Applications and select the Java AWT testapplication.

    4. Click Enable Extensions on the Basic Workflow bar, then select the sample application. SilkTestClassic will prompt you to close and restart the sample application.

    Step 2: Becoming Familiar with the Sample Java AWTApplication

    The sample Java AWT application used in this tutorial is a simple Java application that provides a mix ofpredefined AWT controls along with custom Java objects. For additional information about the AWT, referto the SilkTest Classic Help. Explore the sample Java application to become familiar with it.

    1. Click Start > Programs > Silk > SilkTest > Sample Applications > Java AWT > AWT TestApplication. The Test Application dialog box opens with a menu bar containing four menus.

    2. Click the Control menu, and then click Drawing area. The Drawing Area window opens. It contains acanvas for drawing points and lines with the mouse, an event log that records mouse actions in thecanvas, a Reset button, and an Exit button.

    Java AWT Tutorial | 5

  • 3. Click inside the canvas and drag the mouse to draw points and lines. The mouse actions are recordedin the event log.

    4. Click Exit to close the Drawing Area window.

    5. Experiment with other controls accessible from the Control menu.

    6. Explore other menus in the menu bar of the application.

    The DisabledMenu menu appears grayed out to illustrate how a disabled menu item is supposed tolook. It was not designed to be enabled.

    Step 3: Focusing On a Part Of the Sample Java AWTApplication

    Now that you have become familiar with the Drawing area in the sample Java AWT application, develop atest to verify that mouse events in the canvas are recorded accurately in the event log. We selected theDrawing Area window as a test candidate because it contains both predefined AWT controls and a customJava object. SilkTest Classic allows you to test both types of controls, but before we can create our testframe, we must first identify the custom Java control in the Drawing Area window.

    Step 4: Identifying Custom Controls in the Drawing AreaWindow

    SilkTest Classic provides 4Test class definitions for commonly used Java objects, such as AWT controls.With the Java support of SilkTest Classic, you will be able to use 4Test methods and properties to testJava objects that belong to these predefined classes, which can be found in javaex.inc. For additionalinformation about the AWT or predefined Java classes, refer to the SilkTest Classic Help.

    The SilkTest Classic Java support also enables you to test custom controls, which appear as CustomWinobjects in Java applications. You will need to record classes for custom controls to gain access to theirnative methods and properties. You can then use these native methods and properties to develop scriptsfor testing custom Java objects in the application.

    To identify the custom control