There are many reasons why you should edit and augment a test in Rational Functional Tester. You edit a test to:
- Correct an error or unintended behavior in the test
- Update tests to work with newer application builds
- Separate longer tests into smaller modular tests
- Integrate tests with other automated tests
- Verify functionality or other system requirements
- Associate test data with a test
- Modify or manipulate playback timing
- Modify or control test flow
- Add logging and reporting of test results
- Improve test readability and reuse
The most frequent type of editing you will probably perform to a test script is fixing or updating. After you finish reading this book and start employing the best test script development practices, these corrections and updates should be short and simple. The two general steps in this activity are removing unwanted test script lines and adding new lines. This section does not go into the details of debugging, but it does describe the general editing steps for doing this.
Removing Lines from a Test Script
You can remove unwanted lines of a test script by deleting the lines or by commenting them out (making them into comments). You should begin with the latter because there is always a chance that you might need to restore the original lines. You can comment out multiple lines of a test script as follows:
1. Select the multiple lines of script. This assumes that you know which lines of the test you want to disable.
2. Comment the lines: For Java in Eclipse, choose the menu Script > Toggle Comment or press Ctrl+/. For Visual Studio, choose the menu Edit > Advanced > Comment Selection or press Ctrl+K, and then press Ctrl+C.
Adding Lines to a Test Script
You can add new lines to a test script by inserting a recording into an existing script or by manually adding lines.
It is typically easier to add lines with the recorder. This is easy to do, although you have to ensure that the newly recorded steps flow correctly with the existing recorded steps. You can record new lines into an existing script as follows:
1. Get the application under test to the initial state for the new recording. You can play back the test script in debug mode, breaking (pausing) at the spot where you want to add or rerecord steps.
2. Carefully position the cursor on a blank line in the test script where you want to add new steps.
3. Select Script > Insert Recording from the menu, or click the Insert Recording into Active Functional Test Script button from a toolbar. You immediately go into recording mode.
4. Click the Stop button to finish the recording.
Just as you must ensure the starting point of the new recording is carefully set, you must also ensure that the point that you stop recording flows correctly into the next steps of the test script.
How to Use Test Object Maps
The next most frequent type of editing you are likely do to on a test is update and modify test object maps. A test object map is normally created when you record a new test script, as shown in below Figure . You can also create an object map independently from script recording. Every test script has a test object map to use, and every test object map needs a test script to have a purpose.
Each test script also contains a list of test objects, visible in the script explorer. This is only a subset of all test objects, as shown in below Figure. The list contains only the objects required for this particular test script.
The most common kind of editing that you perform on a test object map is:
- Adding new objects
- Updating objects for a newer version of the application under test
- Modifying object recognition properties
placeOrder().click();
If you want to learn more about this test object, you can open it from the Script Explorer, which opens the test object map and highlights the object as shown in below Figure.
Private Versus Shared
There are two types of test object maps: private and shared. The only difference between the two is that a private map is associated exclusively to one test script, whereas a shared object map can be used by many test scripts. You can open a private test object map from the Script Explorer. You can open a shared test object map from the Project Explorer or from the Script Explorer. The test object map editor and almost all editing capabilities are the same for both private and shared test object maps.
You can create a shared test object map from a private map, and then associate the original test script with the new shared map, changing the private map into a shared one. You can also merge objects from one shared map into another, combining and reducing the number of shared maps. You cannot revert a shared object map back into a private map, but you can merge objects from a shared map into an existing private map.
Ultimately, you need to have primarily shared test object maps instead of private object maps. As a general rule, you should reduce the overall number of different maps.
Adding, Modifying, and Deleting Test Objects
Over time, the objects in the application under test that your test scripts interact with will change. You therefore need to add, modify, and delete test objects in Rational Functional Tester. These changes occur at two levels: in the map containing the test objects and in the test scripts that reference the test objects. The test object map is the primary storage location for a test object. This is where you ultimately maintain the test objects and their current recognition properties.
Adding Test Objects
You can add a new test object to a test script, as shown in below Figure which adds it to the associated test object map as follows:
1. Get the application under test to the point with the object (graphical or other interface object) that you need to add to the test.
2. Position the cursor to a blank line in the test script where you want to add the reference to the new object. This is typically an action on the object, such as clicking or selecting from the object.
3. Select the menu Script > Insert Test Object, which opens the Insert a GUI Object into the Object Map dialog box. This is essentially the same as going into recording mode, except that you do not see the recorder monitor.
4. Use the Object Finder to select the object you want to add, and then click Finish."Selecting an Object"
Insert New Test Object toolbar button
As a consequence, this adds the object to the test object map and to the list of test objects for the script, and it will add a reference to the object in the test script where you positioned your cursor. The initial object reference in the script will not be complete since it will not contain any operation (for example, a click action). You can either manually add the desired operation, assuming that it works with the test procedure recorded in the script, or you can simply comment or delete the line and add some actions for the object at a later time.Selecting an Object
Alternately, you could use the Test Object Browser to select the object you want to add. Refer to the product Help documentation for more information on using the Test Object Browser.
Alternately, you could use the Test Object Browser to select the object you want to add. Refer to the product Help documentation for more information on using the Test Object Browser.
Modifying Test Objects
You can modify a test object by double-clicking on an object in the script explorer, which will open the test object map and highlight the object. If you want to modify an object that is not in the list of test objects in the script explorer, then you can open the test object map and either browse or search to find the object. There are a number of reasons you might modify a test object.
One kind of modification that you can make to a test object that does not require opening the test object map is renaming. You can rename an object directly from the script explorer, as explained in this chapter. Note that you can rename objects from the test object map as well.
Deleting Test Objects
There are two reasons why you might want to delete a test object. First, you may want to remove an object from a test script but leave it in the test object map. You might do this if the object map is shared and the object is used by other test scripts, or you might simply want to leave the object in the map in case you need to add it back into the script at a later time. The second reason you would delete a test object is when you really know that it is no longer needed by any script and you want to delete it from the test object map.
For the first case, when you simply want to remove an object from a script, you can delete an object from the list of test objects in the script explorer. This will not affect the test object map or any other scripts that may use the same map. This also will not remove the reference to the object in the script; you will have to delete or comment the line of code referencing the deleted object yourself. Rational Functional Tester will automatically indicate an error which makes it easier to clean up the script. If you comment out the lines then it will be easier to add it back again later, if needed.
For the second case, when you want to completely delete the object from a test object map, you can open the map and delete the test object. When you do this, Rational Functional Tester will run a short wizard to help ensure you are not deleting something that you need. The first step simply shows the name and recognition properties of the object. The second step, as shown in below Figure, shows all of the test scripts that will be affected by the deletion.
If you realize that you do not want to delete the object you can cancel. Otherwise clicking on Finish will delete the object from the map and all references to the object. Similar to deleting an object from the script explorer, this will not delete the line of code in the script that references the object but it will be reflected in object map as shown in below Figure.
How to Add Verification Points to a Test Script
Verification points are what make test script a test as they are primarily what provide the pass or fail results. You will find that it is generally easier to add verification points when you first record a script. However, you might want to first record the user scenarios and steps and then add verification points later. You might also realize additional or more effective verification points after recording the script. In these cases, you can add verification points as shown in below Figure using following steps:
- Get the application under test to the appropriate point for what you want to check. You might want to play back the test script in debug mode, breaking (pausing) at the spot where you want to add your verification.
- Position the cursor on a blank line in the test script where you want to add the verification point.
- Select the menu Script > Insert Verification Point, which will open the Verification Point wizard. This is essentially the same as going into recording mode except that you will not see the recorder monitor.
- Complete the wizard to create your verification point. You can find more about the verification point wizard in the online Help.
- Click on Finish to return to the test script."Choosing a verification point"
Your choice of verification points should not be arbitrary or chosen on the fly. You should always determine the best way to validate the test case or requirement that the test is implementing. You also need to consider the possibility of errors in proper verification across all test environments and conditions.
Post a Comment