How do I pass a test case while ignoring only certain failed test steps?
I have a test case that has multiple test steps. Two of them are calling a REST endpoint that was not developed by my organization. It's essentially an API for viewing a log. However, sometimes when calling the API, it fails. No payload is returned, no HTTP status is returned, it is a null payload. I have accounted for this by not putting any assertions on the test step and I have a groovy test step right after to evaluate the payload. If the payload is null, I return to the to REST call and run it again. Once it returns a payload, the groovy script will allow the test case to move to the next step.
When the test case completes, if one of the API calls failed the entire test case is failed even though it eventually passed. It seems that the test case is looking at the log and if any test step failed at any point, the test case failed.
How can ignore the failures only for those specific REST calls? If any other test step fails, I still want to the test case to fail. I have attempted to add a script to disable the "Fail TestCase if it has failed TestSteps" option before the REST steps and then re-enable it after they have run, but the test case still fails.
Thank you in advance for any help.
Solved! Go to Solution.
Not possible ootb. You can create a groovy to call the desired step and put the code in a try catch script.
I know it is not possible out of the box. As mentioned, I already have a groovy script to retry the REST step in case of a failure. What I want is to ignore the initial failure of that REST step at the test case level and have the test case pass if all other steps outside this one particular test step pass. Is there a way to manipulate the log files so that the test case thinks the test step passed?
Yes, again I think you can do this with a try and catch statement. I will try to do a demo later today.
Ok so it seems that you don't even have to use a try catch statement. Just disable the step for which you want to ignore the result and call it from a groovy script as:
// Get the test step for which you want to ignore the result def testStep = testRunner.testCase.testSuite.testCases[ "NameOfYourTestCase" ].testSteps[ "NameOfYourTestStep" ] // Run the test step testStep.run( testRunner, context )
I attached a demo project at https://github.com/lucadln/soapui/tree/master/IgnoreFailedStep .
Hey I'm not able to find your demo link, getting 404 error. I need help reagrding my project, where I have to add assertion in all Test Steps using grrovy script, I have written the code for that, but it's considering Groovy Script also as a Test Step and trying to add assertion in it, which is not possible hence my script is failing. How can I identify only Request Test Steps and add assertion into it, by ignoring Groovy Script test Steps.
def testCases = context.testCase.testSuite.getTestCaseList()
log.info "~~~Test Case:" + it.name
for(testSteps in it.testStepList)
log.info "~~~Test Step:" + testSteps.name
def addassert = testSteps.addAssertion("Contains")