What is a Data Member and how is it declared in 4Test?
A Data Member is a variable defined in either a class or a window declaration.
The value of a data member can be an expression, but it is important to keep in mind that data members are resolved (assigned values) during compilation. If the expression for the data member includes variables that will change at run-time, then you must make that data member into a property.
Data Members can be used in data-driven tests where you perform the same test against many objects.
Data added to a window declaration can be used later when testing the object, usually for verification, for example:
- Default values for check boxes and text fields
- Initial control focus for dialogs
- Tab order for dialogs
- Initial state for pushbuttons
- Data used to populate text fields, lists or tables
To declare a Data Member
- Declare a variable data type within an object or class definition
- Specify a name for your new variable (data member)
- You can at this point assign a value but it is not necessary.
Below is an example of data member declared in a window/object declaration;
To use the Data Member in a script
[-] testcase VerifyNumOfChildren () appstate none
[ ] INTEGER iActualNum = ListCount (Support.GetChildren())
[ ] Verify (iActualNum, Support.iNumOfChildren )
Note that you can now refer to the new Data Member directly from the script - Support.iNumOfChildren