RBlack's avatar
RBlack
Occasional Contributor
7 years ago
Status:
New Idea

Unconditionally executing cleanup steps in failing tests

Test cases have Teardown scripts that are unconditionally executed, even if the test fails and stops executing part way.  This is useful to ensure that tests free up any resources they allocated earlier in the test before it failed.

 

However, this encourages all teardown activities to be coded in Groovy, which obscures the symmetry between resource setup in SoapUI test steps and resource teardown in Groovy.  It makes it harder to automatically check (via scripts) for symmetry between resource setup and cleanup.

 

Desired feature: identify some "cleanup" sequence of steps in each test that would execute unconditionally even if the test stops mid-way because of a failure.  This would be akin to the "catch" in Java try-catch-finally.  The analogy could be taken further in that if a step failure or other error occurred during the cleanup steps, the Teardown script would itself execute unconditionally just as it does today.

 

Benefit: hoist and simplify resource cleanup actions out of the Teardown groovy script into the test case itself as real test steps that can be seen in the IDE.  Makes it easier for automation developers to code cleanup steps and verify they are present (opposed to Teardown scripts which tend to hide and be forgotten).  Also makes setup/cleanup actions more amenable to analysis by scripts for the purpose of enforcing verification rules and generating metrics.

 

Thanks.../rob

No CommentsBe the first to comment