Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
508 views
by Contributing Tester (78 points)
retagged by
This is my code:

===============

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

try

{

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

1 like 0 dislike
by Contributing Tester (53 points)

Try this,

sample = testRunner.testCase.testSteps['Login'].testRequest.response.getResponseHeaders()
log.info sample


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...