Loading and Unloading a Compiled Module - WinRunner

In order to access the functions in a compiled module you need to load the module. You can load it from within any test script using the load command; all tests will then be able to access the function until you quit WinRunner or unload the compiled module.

If you create a compiled module that contains frequently-used functions, you can load it from your startup test. For more information, see “Initializing Special Configurations.”

You can load a module either as a systemmodule or as a usermodule. A system module is generally a closed module that is “invisible” to the tester. It is not displayed when it is loaded, cannot be stepped into, and is not stopped by a pause command. A system module is not unloaded when you execute an unload statement with no parameters (global unload).

A user module is the opposite of a system module in these respects. Generally, a user module is one that is still being developed. In such a module you might want to make changes and compile them incrementally.

Note:If you make changes to a function in a loaded compiled module, youmust unload and reload the compiled module in order for the changes to take effect.

load

The load function has the following syntax:

load (module_name [,1|0] [,1|0] );

The module_name is the name of an existing compiled module.

Two additional, optional parameters indicate the type of module. The first parameter indicates whether the function module is a system module or a user module: 1 indicates a system module; 0 indicates a user module.

(Default = 0)

The second optional parameter indicates whether a user module will remain open in the WinRunner window or will close automatically after it is loaded: 1 indicates that the module will close automatically; 0 indicates that the module will remain open.

(Default = 0)

When the load function is executed for the first time, the module is compiled and stored in memory. This module is ready for use by any test and does not need to be reinterpreted.

A loaded module remains resident in memory even when test execution is aborted. All variables defined within the module (whether static or public) are still initialized.

unload

The unload function removes a loaded module or selected functions from memory. It has the following syntax:

unload ( [ module_name | test_name [ , "function_name" ] ] );

For example, the following statement removes all functions loaded within the compiled module named mem_test.

unload ("mem_test");

An unload statement with empty parentheses removes all modules loaded within all tests during the current session, except for system modules.

reload

If you make changes in a module, you should reload it. The reload function removes a loaded module from memory and reloads it (combining the functions of unload and load).

The syntax of the reload function is:

reload (module_name [ ,1|0 ] [ ,1|0 ] );

The module_name is the name of an existing compiled module.
Two additional optional parameters indicate the type of module. The first parameter indicates whether the module is a system module or a user module:1 indicates a system module; 0 indicates a user module.

(Default = 0)

The second optional parameter indicates whether a user module will remain open in the WinRunner window or will close automatically after it is loaded. 1 indicates that the module will close automatically. 0 indicates that the module will remain open.

(Default = 0)

If you try to load a module that has already been loaded, WinRunner does not load it again. Instead, it initializes variables and increments a load counter. If a module has been loaded several times, then the unload statement does not unload the module, but rather decrements the counter.

For example, suppose that test A loads the module math_functions, and then calls test B. Test B also loads math_functions, and then unloads it at the end of the test. WinRunner does not unload the module; it decrements the load counter. When execution returns to test A, math_functions is still loaded.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics