Forum Discussion
testRunner.fail("your reason for failing the test")
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.
- mpartyka7 years agoContributor
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' )
} - nmrao7 years agoChampion Level 3May you should consider creating a separate question with the details instead of reviving an old thread.
- Manoj17 years agoVisitor
Hi All,
As am a beginner in the learning to Groovy, i request you to provide/suggest me the script should read the soap response and log information.
Thanks
Manoj
- Radford7 years agoSuper Contributor
You may find it better to start a new topic as your question doesn't really relate to the original message title. A new message will more likely get more appropriate answers. Anyway, to answer your question...
If you are new to Groovy I would suggest that you have a look at the pint and click Get Data functionality. This will allow you to easily retrieve the a SOAP response by creating the required Property Expansions for you.
Regarding logging, the Groovy Script editors provide a predefined variable "log" (See the section "Editing Groovy test step" of this page) to allow access to the Ready API script log, this object is a Log4J logger.
Related Content
- 2 years ago
- 4 years ago
- 4 years ago
- 5 years ago
Recent Discussions
- 3 hours ago
- 17 days ago