1

I have been using a feature in my test which calls the retry function for calling an end point.

It used to work fine before but in last few days the same code has stopped working .

my code is :

Feature: Invoke External

Background: 
* configure retry = { count: 5, interval: 5000 }

@parallel=false

Scenario: Invoke gateway

Given url externalGateway

And path domain + '/' + basepath + '/' +  path

And header Authorization = accessTokenforProd

And request 'test'

When method requestMethod

Then retry until responseStatus == externalGatewayResponse

Then print ' response code from Qantas External Gateway: ' , responseStatus

and I am calling this feature with the following syntax:

Then def responseFromAuthenticatedExternalWSO2Gateway = call read('classpath:examples/Services/InvokeAuthenticatedProdQantasExternalWSO2Gateway.feature') {'domain': '#(domain)' , 'basepath': '#(basepath)' , 'path': '#(path)' , 'externalGatewayResponse': '#(externalGatewayResponse)' , 'method': '#(requestMethod)' , 'accessTokenforSandbox': '#(accessTokenforSandbox)' }

Then match responseFromAuthenticatedExternalWSO2Gateway.responseStatus == 200

Is there any issue with the syntax? If not , then have we made any changes which might affect the functioning of retry function ?

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
Sneha Shukla
  • 373
  • 1
  • 4
  • 19

1 Answers1

2

Please read the docs: https://github.com/intuit/karate#retry-until

You have got it wrong, the retry until part should be before the method step.

On a related note - especially when I see requestMethod as a variable - I feel you have over-engineered your tests, which I strongly advise against. Avoid using call except for setup kind of stuff - else you will end up with hard to maintain tests.

See this answer for details: https://stackoverflow.com/a/54126724/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks a lot Peter :-) – Sneha Shukla Mar 05 '19 at 23:46
  • Actually i am using some features as main features which contains my tests and some features as service / helpers. So the flow is something like this : Main features runs the test case--> test case makes calls to helpers --> helper does actions like get API ID or invoke a url get response and send back to main features with the result ---> test continues in main feature file with the result form helper services. – Sneha Shukla Mar 05 '19 at 23:50
  • To accomplish this I am using call function and parameterising requestMethod because the invocation is different for different tests and i wanted to keep one single help file for invocation which can handle any method call( get , post , put etc). – Sneha Shukla Mar 05 '19 at 23:51
  • happy to hear your recommendation on this approach. – Sneha Shukla Mar 05 '19 at 23:52
  • @SnehaShukla I have already given my recommendation in the link read it again if needed. reuse beyond a certain extent gives you negative benefit. and in my opinion trying to generalize a get AND post is just asking for trouble. – Peter Thomas Mar 06 '19 at 03:21