Pages: 1 ... 3 4 5 6 7 8 ...9 ...10 11 12 14


  02:33:00 pm, by   , 387 words  
Categories: Uncategorized

Using Metadata


Metadata is similar to annotations in java or attributes in C#. Metadata can be used to mark an object with a value that can be queried at runtime. For example, you can mark all of the app objects in your application with a required field attribute so that a generic test can read the value to determine whether or not to include it in a ‘required field’ test.

Metadata is implemented in Zee as a class. All custom metadata derives from the built-in class Metadata. To add metadata to an AppObject, first create a class as in the example below:

class  CustomData : Metadata   
String  System  
Integer Version

Then apply the metadata to your AppObjects and assign values as in the example below.  The order of the members inside the square brackets does not matter since field/value pairs are used:

WebPage MyPage   
WebTextField MyTextField    %CustomData[System="MySystem",Version=3]

In the previous example, each member of the metadata class was assigned using a field/value pair. An alternate way to assign metadata is to list the members in order as in the example below:

WebPage MyPage   

WebTextField MyTextField  %CustomData["MySystem",3]

To refer to metadata in functions and tests, use the % operator as in the example below:

String SystemName = MyPage.MyTextField.%CustomData.System

It is also possible to create a metadata class without member elements as in the example below. In this case the value of the metadata will be false if it is not assigned to an AppObject. Otherwise it will return true.

class ObsoleteIndicator : Metadata

WebPage MyPage

WebTextField MyTextField %ObsoleteIndicator  
WebTextField MyTextField2 

Print (MyPage.MyTextField.%ObsoleteIndicator)
//Prints  true

Print (MyPage.MyTextField2.%ObsoleteIndicator)
//Prints   false

Here are some notes to enhance your understanding of Metadata:

  • Metadata can not be inherited.
  • It is not necessary to assign all members of a metadata class to an AppObject. If a member that is not assigned a value is accessed at runtime, a null value will be returned.
  • If the members of the metadata class are assigned to an AppObject in order without using the name of the member, members must not be skipped, but it is not necessary to assign all members of the class.
  • The fields in a metadata class are constants. If they are listed in a metadata assignment, they must be provided with a value.
  • The following classes are supported for metadata member elements: Boolean, Date, DateTime, Enumerated Type, Flags, Integer, List, Number, Real, Record, String, Time and Type.

1 ... 3 4 5 6 7 8 ...9 ...10 11 12 14

Zeenyx Software is committed to providing a solution for manual and automated testing that will allow all members of the team to build effective tests faster than with traditional manual testing methods so that a positive Return on Investment is achieved the very first time tests are deployed.


  XML Feeds

blog engine