Forum Discussion

tristaanogre's avatar
tristaanogre
Esteemed Contributor
14 years ago

Geeking out over something here... Thanks, SmartBear

In a previous "life", I did a lot of code work in an automation framework utilizing some pretty extensive networks of DDT drivers and ODT objects and classes.  I declared my ODT classes in code because there were times when, as new features got implemented, we'd need to add properties or methods to classes to accommodate.  That was a lot easier to write out in code than manually editing the ODT class in the GUI and then having to version and track the changes in the resultung ODT.xml file.  That and I could add comments, etc.



So, let's say I had a class that I needed to declare say, for example, a customer record.  That customer record would potentially have other classes that would be different properties, such as primary contact, address, etc.  What I USED to do (in TC 6 at least), was declare the "child" classes first and then build them into the "customer class".  Like so:



procedure DeclareAddressClass;



var

LocalClass;



begin

if ODT.Classes.Items['Address'] <> aqObject.VarEmpty then

     ODT.Classes.Delete('Address');

LocalClass := ODT.Classes.Declare('Address');

LocalClass.AddProperty('Street1');

LocalClass.AddProperty('Street2');

LocalClass.AddProperty('City');

LocalClass.AddProperty('State');

LocalClass.AddProperty('ZIP');

end;



procedure DeclareCustomerClass;



var

LocalClass;



begin

if ODT.Classes.Items['Customer'] <> aqObject.VarEmpty then

    ODT.Classes.Delete('Customer');

LocalClass := ODT.Classes.Declare('Customer');

LocalClass.AddProperty('Name');

LocalClass.AddPropOfClassType('Address', 'Address');

end;




This was bulky because if I wanted to declare the customer class I needed to first declare the address class or nothing worked right.  What would happen is that I would end up writing another procedure that would declare all my "child" classes in order followed by my "parent" class.  What a pain!



Well, I don't know how long this has been in here, but at least in TC 8.5, I can do the following.



procedure DeclareCustomerClass;



var

LocalClass, LocalProperty;

begin

if ODT.Classes.Items['Customer'] <> aqObject.VarEmpty then

    ODT.Classes.Delete('Customer');

LocalClass := ODT.Classes.Declare('Customer');

LocalClass.AddProperty('Name');

LocalProperty := LocalClass.AddPropOfClassType('Address', 'Address');

if not IsSupported(LocalProperty, 'Street1') then LocalProperty .AddProperty('Street1');

if not IsSupported(LocalProperty, 'Street2') then LocalProperty .AddProperty('Street2');

if not IsSupported(LocalProperty, 'City') then LocalProperty .AddProperty('City');

if not IsSupported(LocalProperty, 'State') then LocalProperty .AddProperty('State');

if not IsSupported(LocalProperty, 'ZIP') then LocalProperty .AddProperty('ZIP');

end;




The result is that actually TWO classes are declared in the ODT object of TestComplete within one declaration statement.  And the Address class is then reusable in other class declarations and objects.



So, when I declare the customer class, all I need is the initial declaration statement and everything else is taken care of.



Thanks, Smartbear, for this feature.  Again, it might have been there all along, but you've just made me VERY happy with this revelation.
No RepliesBe the first to reply