Alex Tereshenkov
Alex Tereshenkov

Reputation: 3620

How to call certain steps even if a test case fails in SOAP UI to clean up before proceeding?

I use SOAP UI for testing a REST API. I have a few test cases which are independent of each other and can be executed in random order.

I know that one can disable aborting the whole run by disabling the option Fail on error as shown in this answer on SO. However, it can be so that the TestCase1 has prepared certain data to run tests first and it breaks in the middle of its run because an assertion fails or for some other reason. Now, the TestCase2 starts running after it and will test some other things, however, because TestCase1 has not had its all steps (including those that clean up) executed, it may fail.

I would like to be able to run all of the tests even if a certain test fails however I want to be able to execute a number of particular test case specific steps should a test fail. In programming terms, I would like to have a finally where each test case will have a number of steps that will be executed regardless of whether the test failed or passed.

Is there any way to achieve this?

Upvotes: 0

Views: 832

Answers (1)

Gaurav Khurana
Gaurav Khurana

Reputation: 3936

You can use Teardown script at test case level

In below example test step fails but still teardown script runs. So its more like Finally

Alternatively you can try creating your own soft assertion which will not stop the test case even if it fails. for example

def err[]

then whenever there is an error you can do

err.add( "Values did not matched")

at the end you can check

assert err.size()>0 ,"There is an error"

log.info err

This way you can capture errors and do actual assertions at the end or alternatively you can use the below teardown script provided by SoapUI

enter image description here

Upvotes: 2

Related Questions