Forum Discussion
I have used the code flow you mentioned , but my problem is when I throw the error after 3rd attempt, nothing happens.The assertion should fail and test run should stop. But ,the assertion is marked OK and the runner just moves on to the next step
- srishtiK9 years agoOccasional Contributor
if(tokenCountValue<=3){
messageExchange.modelItem.testStep.testCase.getTestStepByName("fetchAuthId").run(context.getTestRunner(),context)
}
else{
context.getTestRunner().fail("Service Failed with 401 Authorizarion Error")//throw new Error ("Service Failed with 401 Authorizarion Error")
}
Neither of the error methods work
- nmrao9 years agoChampion Level 3But you can't directly tell 401 error. Instead it has to read from the fetchAuthId test step response headers, Isn't it?
- srishtiK9 years agoOccasional Contributor
fetchAuthId will simply give me an authId. I need to use this authId in a different test step . If this other test step status is 401 I need to go back to fetchAuthId and generate a new authId and run the other test step again. I should be able to re run fetchAuthId only thrice after which I must fail this other test step and the test run also
I check the status in the other test step as :
def status = messageExchange.getResponseStatusCode();
if(status == 401){
tokenCountValue = tokenCountValue+1;
if(tokenCountValue<=3){
messageExchange.modelItem.testStep.testCase.getTestStepByName("GetToken").run(context.getTestRunner(),context)
}
else{
context.getTestRunner().fail("${name} Service Failed with 401 Authorizarion Error")
}
Related Content
- 4 years ago
Recent Discussions
- 3 days ago