Testing JFC Components: Testing a Simple JFC Component


Actually, you don't need the NCL to test simple JFC components that don't contain other components. JavaStar can locate these components. To demonstrate this, test a slider to see if it is set at the correct value.

  1. Click Create Test Script. Use the application that you set up in the project. Click Start.
    It takes a while for the SwingSet applet to load.

  2. Record the script. Name it testSlider.

  3. Return to the SwingSet applet. Select the tabbed pane "Slider".
    Notice that the NCL is used to locate a tabbed pane. Here is the JavaStar code:

  4. Verify the value shown on a slider. Click Verify on the Record/Playback window. When asked to select an object, select any slider.
    You should see the JSlider object in the verify panel. The code is something like this (it varies depending on which slider you chose).

  5. JavaStar will suggest using the attributes in the gold file as the default. Click Customize to use a method of a JSlider to check just the value.
    If you used the gold file, JavaStar would compare all significant attributes of the slider.

  6. Click on the Using simple methods and data members radio button. Click on Select simple methods and data members to see a list of the members.

  7. Scroll through the list and select the method getValue(), and click Enter a purpose.

  8. Click Insert the verification into test. The code in the script should be similar to this:

  9. Click Continue, then stop the recording.

  10. Playback the recording.

As you can see, testing a simple JFC component is not very different from testing an AWT component. You can do everything you could with an AWT component. As you'll see in the next section on Menu components, you can do more with some items.




Send feedback to JavaStar-feedback@suntest.com
Copyright © 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303. All rights reserved.