I have code that looks like this:
scenario("Test Service") .exec( SessionVariables.initialize ) .during( Test.duration ) { feed( User.feed.random ) .exec( RTDE.Login.sequence ) **.exitHereIfFailed** .exec( RTDE.SomeService.GET .request .check( jsonPath( "$" ).saveAs( RESPONSE_BODY ) ) ) }
I did that (.exitHereIfFailed) because if the login fails, there is no point in going on. But I don’t want the whole scenario to end, I just want to skip the rest of the loop body. Like this:
`
during( time ) {
login
if ( ! failed ) {
continue the test
} else {
log the user information that failed, for investigation
reset the fail flag so we can continue the loop
}
}
`
How to do that does not appear to be documented (that I can find). So, digging in the code, it looks like I would do it like this:
`
.during( Test.duration ) {
feed( User.feed.random )
.exec( RTDE.Login.sequence )
.doIfOrElse( session => session.status == OK ) {
// …
} {
// log failure
.exec( session => session.markAsSucceeded )
}
}
`
Seems to work. But is that the way it is meant to be done, or is there an easier way that I did not come across yet?