cancel
Showing results for 
Search instead for 
Did you mean: 

how to get method and status for the testcases

SOLVED
Highlighted
Contributor

how to get method and status for the testcases

how to get method and status for the corrosponding test cases .

below is my script,when i ran this script for testStepName i got all the list of teststeps for the testcase(Ref:-ss1) but for method and StatusCode i found error(ref-ss2),it should work.attached  doc for ref,need help.

 please let me know highlight below is correct or not ?

 

def testStepName
def method
def statusCode
testCase.testStepList.each {
testStepName = it.name
method = it.getHttpRequest().getHttpResponse().getmethod()
log.info method
statusCode = it.testRequest.Response.ResponseHeaders["#status#"][0]
log.info statusCode
}

2 ACCEPTED SOLUTIONS

Accepted Solutions
Contributor

Re: how to get method and status for the testcases

this is not working,observed below error.

Error detail

com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of TS1_global offer override Flag_Verification

 

below  is the code which is working fine-attached SS detail for ref.

script detail

def testStepName
def method
def statusCode
def endpointURL
testCase.testStepList.each{
testStepName = it.name
if(testStepName == "Request_GlobalOffersAvailable_Flag") {
method = it.getHttpRequest().getResponse().getMethod()
statusCode = it.testRequest.response.responseHeaders["#status#"][0]
endpointURL = it.getHttpRequest().getResponse().getURL()
log.info method
log.info statusCode
log.info endpointURL
}
log.info testStepName
}
Community Manager

Re: how to get method and status for the testcases

Hi Amarnath1234,

 

Just to clarify - does the last script you posted do what you want?

If it does, it's worth marking your reply as a solution (just click the Accept as Solution button next to the reply).

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
4 REPLIES 4
Community Manager

Re: how to get method and status for the testcases

Hi Amarnath1234,

 

Take a look at this post  - it describes how to get the status of a testcase.

 

Also, there are several useful articles in our TechCorner resource, for example, this one:

https://community.smartbear.com/t5/SoapUI-Pro/Operating-with-TestCase-properties-Groovy/m-p/169106

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Community Leader

Re: how to get method and status for the testcases

Hi Amarnath1243,

 

Please use below code to fetch the method name and status code for REST Request.

def testStepName = testRunner.testCase.getTestStepByName("REST REQUEST")
def method = testStepName.getRestMethod().getMethod()
log.info method
def statusCode= testStepName.testRequest.response.responseHeaders["#status#"][0]
log.info statusCode

Let me know for any concerns.

Contributor

Re: how to get method and status for the testcases

this is not working,observed below error.

Error detail

com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of TS1_global offer override Flag_Verification

 

below  is the code which is working fine-attached SS detail for ref.

script detail

def testStepName
def method
def statusCode
def endpointURL
testCase.testStepList.each{
testStepName = it.name
if(testStepName == "Request_GlobalOffersAvailable_Flag") {
method = it.getHttpRequest().getResponse().getMethod()
statusCode = it.testRequest.response.responseHeaders["#status#"][0]
endpointURL = it.getHttpRequest().getResponse().getURL()
log.info method
log.info statusCode
log.info endpointURL
}
log.info testStepName
}
Community Manager

Re: how to get method and status for the testcases

Hi Amarnath1234,

 

Just to clarify - does the last script you posted do what you want?

If it does, it's worth marking your reply as a solution (just click the Accept as Solution button next to the reply).

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Top Kudoed Authors