Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

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

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


def groovyUtils = new 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"Testcase is Passed")


catch(AssertionError e)

{"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() sample
answered by (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.