Forum Discussion

HP-Plano-TX-Soa's avatar
HP-Plano-TX-Soa
Occasional Contributor
12 years ago

[Resolved] How to get the type of a testStep?

I have the following in a testCase teardown script:

// Log the testCase name, status and all the testStep messages
//
testCaseName = testRunner.testCase.name
log.info testCaseName

if ( testRunner.getStatus().toString() == 'FAILED' )
{
log.info "$testCaseName has failed"
}
else
{
log.info "$testCaseName has Passed"
}

for ( testStepResult in testRunner.getResults() )
{
tstype = testStepResult.config.type
log.info tstype
tsname = testStepResult.testStep.name
myRequestStep = testRunner.testCase.getTestStepByName("$tsname")
request = new String(myRequestStep.testRequest.messageExchange.rawRequestData)
response = new String(myRequestStep.testRequest.messageExchange.rawResponseData)
sts = testStepResult.getStatus().toString()
log.info "$tsname has " + "$sts"
log.info "$tsname: RAW REQUEST: " + request
log.info "$tsname: RAW RESPONSE: " + response
testStepResult.messages.each() { msg -> log.info tsname + ": " + msg }
}

The statement in bold causes an error because there exists no "config" object for getResults(). What I am trying to do here is to log only the Requests and Responses for Soap-type test steps. Delays, groovy etc test steps don't have the Request and Response objects, obviously.

So how do I get the type of a test step in this loop, so that I can avoid trying to get the Response and Request objects on test steps that don't have such objects?

Thanks much!
  • Answered my own question:

    Have to get a handle to the testStep before I can get its Type:

    for ( testStepResult in testRunner.getResults() )
    {
    testStep = testStepResult.getTestStep()
    tstype = testStep.config.type
  • HP-Plano-TX-Soa's avatar
    HP-Plano-TX-Soa
    Occasional Contributor
    Answered my own question:

    Have to get a handle to the testStep before I can get its Type:

    for ( testStepResult in testRunner.getResults() )
    {
    testStep = testStepResult.getTestStep()
    tstype = testStep.config.type