Welcome to the Question and Answer site for Software Testing Professionals

You can get your queries resolved from Software Testing Professionals.

Ask a Question

Get answers and give answers to questions from other members.

View All Questions

Get votes and earn points to build your reputation in community.

View Hot Questions

SoapUI pro using groovy language, unable to get valid output out of the assert statement.

Open 1 Answers 17 Views
0 1
This is my code:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )



def httpResponseHeaders = context.testCase.testSteps["Login"].testRequest.response.responseHeaders

def ActualStatus = httpResponseHeaders["#status#"]

def expectedHTTPResponse = ['HTTP/1.1 200 OK']

assert expectedHTTPResponse == ActualStatus //validate status here

log.info("Testcase is Passed")


catch(AssertionError e)


log.info("Testcase is Failed")


If I run the groovy script individually, its show the correct result for valid data(Actual Status=ExpectedStatus).Now, when I run the testcase[login and groovy script, 2 steps], it will show the correct result as "Pass". I am using assert to validate the status. Again when I am passing invalid data(Actual Status!=ExpectedStatus) and running the groovy script individually, it will show the result as "Testcase is failed". And when I run the test case [login and groovy script, 2 steps], it will show the correct result as "Pass". Actually, it is suppose to fail.

How to handle assert to validate the status?

1 Answer


Try this,

sample = testRunner.testCase.testSteps['Login'].testRequest.response.getResponseHeaders()
log.info sample
answered 2 days ago by viveksrinivas (53 points)

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

We have resolved 1.2k+ Software Testing queries!

Software Testing Board Weekly update

We will send you handpicked questions that you would love to answer.

View previous campaigns.

Top Contributors