To implement data correlation for test generation, become familiar with these classes:
Implement data correlation for test generation
- com.ibm.rational.test.lt.datacorrelation.testgen.proto.IProtoElementAdapter
- com.ibm.rational.test.lt.datacorrelation.testgen.DataCorrelator
- com.ibm.rational.test.lt.datacorrelation.testgen.IDCStringLocator
To implement data correlation for test generation and script editing, model elements must extend...
- com.ibm.rational.test.lt.models.behavior.data.DataSource
- com.ibm.rational.test.lt.models.behavior.data.Substituter
...so that you can associate data sources and substituters with model elements. Also, when you extend those classes, make sure you implement the code to make Substituters and DataSources persist in model. For more information, refer to the model documentation.
You need to create own data correlation plug-in to extend the extension point DCTestgenProto, which is defined in the plug-in...
com.ibm.rational.test.lt.datacorrelation.testgen
To extend the extension point, code must implement the interface IProtoElementAdapter which is defined in...
com.ibm.rational.test.lt.datacorrelation.testgen.proto
Then, when you extend the DCTestgenProto extension point, use the following items:
ID This is the unique ID of extension. Name The name that is meaningful for you. Point com.ibm.rational.test.lt.datacorrelation.testgen.DCTestgenProto extension point The other element details are:
class Full name of the class (including plug-in name) that implements IProtoElementAdapter. protoType Type of model element that this plug-in handles, for example, in HTTP, the model element that is handled is... com.ibm.rational.test.lt.models.behavior.http.HTTPRequest
generic Boolean that can be true or false. If it is true, this means that if there are other plug-ins that handle the same protoType, this plug-in will be called last. uniqueID This ID is unique among all data correlators.
After you have extended the data correlation extension point, the main data correlation engine will call code with all the elements of the model type that you defined.
There are two parts to data correlation at testgen time. The first part is automatic data correlation which happens at testgen time. This will happen through a call to...
DataCorrelator.CorrelateAll()
When this method is called automatically by testgen, it will in turn call two main methods in plugin. Those methods are...
- IProtoAdapter.findSubs()
- IProtoAdapter.findReference()
The findSubs() method should return a list of substituters that are found for the current element that is passed into method, and null if there were no substituters found.
The findReference() method should try to find a reference for the substituter passed into it.
You start looking for references at the element before the substituter and keep working backwards in the testsuite until you find a suitable reference. If no reference is found, return null. CorrelateAll is used to find all correlations that you can so that the user does not have to manually find them at test editing time.
The other parts of the IProtoAdapter class are called at test editing time when a user wants to create a substitution site, a reference, or make a correlation between a substitution site and a reference. If you are creating own type of Substituters or DataSources, makeDataSource() and makeSub() methods will be used for that. You will be passed the DCStringLocator class with all the information about offsets and text that you need. Use this DCStringLocator to determine what substituter or data source to create and then call back into IDataCorrelator. Correlations, substituters, and data sources are created in the model for you. Read the documentation on the IDataCorrelator class to learn which methods are right for purposes.
Related tasks
Implement data correlation for execution