Questo codice di esempio mostra il TestObject Java™:
package sdk.sample; import com.rational.test.ft.object.interfaces.*; import com.rational.test.ft.object.TestObjectReference; import com.rational.test.ft.object.map.SpyMappedTestObject; public class ExtendedGuiTestObject extends GuiTestObject{ // FIVE Standard Contructors, has to be defined in every new TestObject public ExtendedGuiTestObject(SpyMappedTestObject mappedObject) { super(mappedObject); } public ExtendedGuiTestObject(SpyMappedTestObject mappedObject, TestObject anchor) { super(mappedObject, anchor); } public ExtendedGuiTestObject(SpyMappedTestObject mappedObject, TestObject anchor, long scriptCommandFlags) { super(mappedObject, anchor, scriptCommandFlags); } public ExtendedGuiTestObject(TestObjectReference ref) { super(ref); } public ExtendedGuiTestObject(TestObject obj) { super(obj); } // Newly added Method for this TestObejct, just a call forwarder using invokeProxy API public void performClick() { invokeProxy("performClick"); } }
Questo codice di esempio mostra il TestObject .Net:
using TestObjectReference = Rational.Test.Ft.Object.TestObjectReference; using Rational.Test.Ft.Object.Interfaces; using Rational.Test.Ft.Object.Manager; using Rational.Test.Ft.Object.Map; namespace SDK.Sample { public class ExtendedGuiTestObject:GuiTestObject { // FIVE Standard Contructors, has to be defined in every new TestObject public ExtendedGuiTestObject(SpyMappedTestObject mappedObject):base (mappedObject) { } public ExtendedGuiTestObject(SpyMappedTestObject mappedObject, TestObject anchor) :base (mappedObject, anchor){ } public ExtendedGuiTestObject(SpyMappedTestObject mappedObject, TestObject anchor, long scriptCommandFlags):base (mappedObject, anchor, scriptCommandFlags) { } public ExtendedGuiTestObject(TestObjectReference ref_Renamed):base (ref_Renamed) { } public ExtendedGuiTestObject(TestObject obj):base (obj) { } // Newly added Method for this TestObejct, just a call forwarder using InvokeProxy API public virtual void PerformClick() { InvokeProxy("performClick"); } } }
Questo esempio mostra come è possibile definire nuovi nomi canonici per un TestObject:
<?xml version="1.0" encoding="UTF-8"?> <ConfigFile L=".ConfigFile"> <Section L=".ConfigFileSection"> <Name>proxies</Name> <Val L=".ProxyManager"> <DomainImplementation L=".DomainImplementation"> <Name>Net</Name> <Obj L=".Proxy"> <ClassName>[NETProxyExtension]SDK.Sample.TestButtonProxy</ClassName> <Replaces/> <UsedBy>Rational.Controls.CustomButton</UsedBy> </Obj> </DomainImplementation> </Val> </Section> <Section L=".ConfigFileSection"> <Name>testObjects</Name> <Val L=".TestObjectManager"> <ComponentModel L=".ComponentModel"> <Name>Java</Name> </ComponentModel> <ComponentModel L=".ComponentModel"> <Name>Net</Name> <Obj L=".TestObject"> <CanonicalName>ExtendedGuiTestObject</CanonicalName> <TestObject>[NETProxyExtension]SDK.Sample.ExtendedGuiTestObject</TestObject> </Obj> </ComponentModel> <ComponentModel L=".ComponentModel"> <Name>Java</Name> <Obj L=".TestObject"> <CanonicalName>ExtendedGuiTestObject</CanonicalName> <TestObject>sdk.sample.ExtendedGuiTestObject</TestObject> </Obj> </ComponentModel> </Val> </Section> </ConfigFile>
Questo esempio mostra l'origine proxy Java che sovrascrive il metodo getTestObjectClassName():
import com.rational.test.ft.domain.*; . . public String getTestObjectClassName() { return "ExtendedGuiTestObject"; // the canonical name for the newly created testObject }
Questo esempio mostra il proxy .Net che sovrascrive il metodo GetTestObjectClassName():
using Rational.Test.Ft.Domain;. . public override System.String GetTestObjectClassName() { return "ExtendedGuiTestObject"; // the canonical name for the newly created testObject }