Forum Discussion
- M_McDonaldSuper ContributorI think this should work.
testRunner.fail("your reason for failing the test")
- krabhishek_30Occasional Contributor
testRunner.fail() fails the whole test case.
I have a test case where
- I run a http call,
- validate data returned by the call and then,
- iterate to the http call
This keeps on happening until a condition is satisfied.
The problem is, when i use testRunner.fail() it fails the whole test case and the iteration stops. I want to fail the current iteration and then move on to next iteration.
Is there a way.
- mpartykaContributor
try this ?.
- run a http call,
- validate data returned by the call with an assertion (either as separate assertion test step, or on the http call itself)
- groovy step to direct flow to appropriate test step based on assertion status
- loop back to the http call if test assertion fails
- jump to final test step if assertion passes
Note: TestCase option 'Abort on Error' must be unchecked (option set on the entire test case) or the test will stop processing with the first failure.
groovy would be similar to this ...
def assert_status_token = testRunner.testCase.getTestStepByName("Assertion").getAssertionStatus().toString()
if (assert_status_token == 'FAILED')
{
testRunner.gotoStepByName( 'RecordErrors' )
}
else
{
testRunner.gotoStepByName( 'DataSource Loop' )
}
- solaiNew Contributor
Hi,
Am trying to run groovy script step that internally executes REST test step based on the provided input data (reads from excel), here am trying to fail the test case in the groovy step based on the returned assertion status using testRunner.fail() this works properly while executing only the groovy test step but if I run through the whole test case it's not iterating and struck in the second iteration Any idea to solve this ?
- RadfordSuper Contributor
Have you checked the test case basic options for your test case that contains the test step in question? In particular the "Fail Test Case on Error" option.
- solaiNew Contributor
Yes that one is unchecked
Related Content
- 2 years ago
Recent Discussions
- 3 hours ago
- 17 days ago