This documentation supports the 20.02 version of BMC Helix Platform.To view the documentation for the current version, select 20.08 from the Product version menu.

Automation framework methods


The automation framework provides a comprehensive set of methods that ease your tasks while creating test cases for your application. The following sections describe the different classes and methods provided by the automation framework.

BaseTest class

The BaseTest class is located in the com.bmc.rx.test.framework package. You can extend the BaseTest class to create your test cases. You can find the sample code for the BaseTest class in the Task Manager automation project. The Task Manager automation sample project provided in the BMC Helix Platform SDK. For information about use of automation framework in Task Manager application, see Example-of-using-automation-framework.

For information about the methods available in the BaseTest class, see API documentation.

Note

To access the automation framework API Java documentation, download the AutomationAPIJavaDocumentation file and unzip the contents of the Zip file and open the index.html file.

TestHelper class

The TestHelper class is located in the com.bmc.rx.test.framework.connection package. The TestHelper class provides the following methods:

Method

Description

Sample code

String dateToJsonDate(Date date)

This method converts a Java date object to a valid ISO 8601 formatted string.

The following is the string format:

"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

Date date = new Date();  //04/07/2017 09:40:46 PDT
String stringDate = TestHelper.dateToJsonDate(date); //2017-07-10T09:40:46.894Z

String createClassName(String name)

This method converts a string to a Java variable name.

String name = "Test 012#@";
String fixedName = TestHelper.createClassName(name);//Test_012__

List<BaseRecordInstance> LoadRecordInstanceFromCSVFile(String fileName, String className)

This method loads record instances from a CSV file.

Excel Example( first row is a header with field names):
Creator,Status
Demo,New
Demo2,Assigned

List<BaseRecordInstance> records = TestHelper.LoadRecordInstanceFromCSVFile("test.csv", "TaskRecordInstance");
TaskRecordInstance teskRecordInstance = new TaskRecordInstance(records.get(0));
server.createRecordInstance( teskRecordInstance);

Hashtable<String, BaseRecordInstance> LoadRecordInstanceFromJSONFile(String fileName, String className)

This method loads record instances from a JSON file.

 

JSON Example( 2 RECORDS):
[
{"name":"testRecord1","data":[{"name":"Creator","value":"Demo"},{"name":"Status","value":"New"}]},
{"name":"testRecord2","data":[{"name":"Creator","value":"Demo2"},{"name":"Status","value":"Assigned"}]}
]

Hashtable<String,
BaseRecordInstance> records =
TestHelper.LoadRecordInstanceFromJSONFile("test.txt",
"TaskRecordInstance");
Set<String> keys2 = records.keySet();
for(String key2: keys2){
      TaskRecordInstance teskRecordInstance = new TaskRecordInstance(records.get(keys2));
      server.createRecordInstance( teskRecordInstance);
}

For more information about the methods available in the Testhelper class, see API documentation.

Note

To access the automation framework API Java documentation, download the AutomationAPIJavaDocumentation file and unzip the contents of the Zip file and open the index.html file.

TestServer class

The TestServer class is located in the com.bmc.rx.test.framework.connection package.

The following table describes the PostRequestwithAssoc method available in the TestServer class:

Method

Description

Sample code

createRecordInstanceWithAssoc(RecordInstance, assoc)

This method creates a record instance and its associated record instances.

/* This method creates a record instance as well as associated record Instances.
     An example if provided in the Task Manager automation project. */

<pre>
         {@code
             String groupGUID = findGroupGUIDByName(groupName);
             AssociateOperation ao = new AssociateOperation();
             ao.setAssociationDefinitionName("com.example.taskmanager-lib:Task To Task Group Customers");
             ao.setNodeSide(NodeSide.nodeB);
             ArrayList<String> recordInstanceIds = new ArrayList<String>();
             recordInstanceIds.add(groupGUID);
             ao.setRecordInstanceIds(recordInstanceIds);
             TaskRecordInstance task = new TaskRecordInstance();
             ArrayList<AssociateOperation> assoc = new ArrayList<AssociateOperation>();
             assoc.add(ao);
             taskId = serverREST.createRecordInstanceWithAssoc(TaskRecordInstance.bundleName, task, assoc);
          }
     </pre>
    
      @param entry  (BaseRecordInstance)   BaseRecordInstance object to create {@link BaseRecordInstance}. It will be automatically casted to a RecordInstance object.
      @param assocs (List AssociateOperation)   List of associated Record instances
      @return (String)     Record Request Instance ID of the created Record Instance.
      @throws RxServicesException Exception
      @throws JSONException       Exception

For information about the methods available in the TestServer class, see API documentation.

Note

To access the automation framework API Java documentation, download the AutomationAPIJavaDocumentation file and unzip the contents of the Zip file and open the index.html file.

Related topic

Testing application logic with the automation framework

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*