Forum Discussion
nmrao
10 years agoCommunity Hero
You can be able to achieve this using groovy script:
1. step is to get auth id
2. groovy script which I am proposiing -
sudo code:
Initialize a counter to 1 as 1st step already run
Do below steps If counter is less than or equal to 3, throw error otherwise.
read first step response.
if the response has 401, go first step
if the response has authId, do the required steps and go to next step.
1. step is to get auth id
2. groovy script which I am proposiing -
sudo code:
Initialize a counter to 1 as 1st step already run
Do below steps If counter is less than or equal to 3, throw error otherwise.
read first step response.
if the response has 401, go first step
if the response has authId, do the required steps and go to next step.
srishtiK
10 years agoOccasional Contributor
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
- nmrao10 years agoCommunity HeroPlease post your script
- srishtiK10 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
- nmrao10 years agoCommunity HeroBut you can't directly tell 401 error. Instead it has to read from the fetchAuthId test step response headers, Isn't it?