Examples: Adding a new TestObject

This example explains how to add a new TestObject.

About this task

To create, build, and deploy the TestObject:

Procedure

  1. Create the constructors for the TestObject.

    This example code shows the Java™ TestObject:

    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");
    	}
    }

    This example code shows the .Net TestObject:

    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");
    		}
    	}
    }
  2. Define new canonical names for the TestObject in the customization file.

    This example shows how you can define new canonical names for a 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>
  3. Map proxies to the newly created TestObject.

    This example shows the Java proxy source overriding getTestObjectClassName() method:

    import com.rational.test.ft.domain.*;
    .
    .
    public String getTestObjectClassName()
    {
        return "ExtendedGuiTestObject";  //  the canonical name for the newly created testObject
    }

    This example shows the .Net proxy overriding GetTestObjectClassName() method:

    using Rational.Test.Ft.Domain;.
    .
    public override System.String GetTestObjectClassName()
    {
       return "ExtendedGuiTestObject";  //  the canonical name for the newly created testObject 
    }
  4. Build the TestObject binary files.
  5. Deploy the TestObject binary files by copying the files to the Functional Tester customization directory, C:\ProgramData\HCL\HOTUI\customization.
  6. Restart HCL OneTest™ UI.
Feedback