Forum Discussion

Gordon_McNair's avatar
Gordon_McNair
Contributor
14 years ago

Using the WADL to drive the testing of the responses

Hello,

This is a request that came from one of our test developers.

I build the request based on 2 things the data and the request definition from the WADL. I do this by relying to the naming convention that the name of the property in the datasource exactly matches the name of the property in the restRequest as defined by the WADL. The result of this is that building the body checks the request definition and then based on the list of allowed properties populates the message body (if data has been provided for that field)To illustrate (code snippet):


targetStepHolder.properties.each(){element -> //for every property of the RestRequest Step
if (element.value.toString() ==~ /.*RestTestStepProperty.*/){ //test to see of the property is from the WADL or from soapUI
if (element.key == 'session') {
if (dataStepHolder.properties[element.key].value == "") {
jsonMap.addElement(element.key, formSessionID, "string")
}else {
jsonMap.addElement(element.key, dataStepHolder.properties[element.key].value, "string")
}
}else {
if (dataStepHolder.properties[element.key] == null){
// there is no property here
logHolder.error("There is no data column for " + element.key + " in the data store")
}else{
if(dataStepHolder.properties[element.key].value != ""){
if ( element.value.getType() ==~ /.*string/){
jsonMap.addElement(element.key, dataStepHolder.properties[element.key].value, "string")
}else {
jsonMap.addElement(element.key, dataStepHolder.properties[element.key].value,"non-string")
}
}//end if data column has no data
}//end else data step has not column branch
}//end if property is a rest element
}//end loop for each property


What I’d like to be able to do:

I’m looking to use the WADL to drive the testing of the responses in the same way I’m using it to drive the message body building scripts.

What I need to do this is the collection of properties that the WADL has defined as the ‘Response’ I’ll then use this to interact with the datasource (for all but a couple of exceptions)

However I can’t find anything that indicates how to get at the transaction’s defined response fields from the testStep in the same way that I am with the inputs.

I’m wondering if this is possible and if so how.

Thanks for any help you can provide.

Regards,
Gordon.

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Gordon,

    you can access the an object-hierarchy for the wadl-definition itself with

    // get application object of WADL
    def app = testRunner.currentTestStep.testRequest.operation.service.definitionContext.interfaceDefinition.application

    // parse as desired
    ...

    Could this help you forward?

    regards!

    /Ole
    eviware.com