question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

callonce feature not working properly

See original GitHub issue

Hi Peter!

I am having a quite nice experience with Karate so far, thanks for the continued effort! 😃

I am working with a feature with the following design:

Background: 
 * def xyz = callonce read('classpath:abc.feature')
 * configure headers = read('headers.js')

Scenario: Does something

Scenario: Does something else

Let’s say abc.feature it is a feature that authenticates my user and sets headers accordingly. From the execution logs, I am seeing:

...
cached callonce: read('classpath:abc.feature')
...

But the abc.feature is being invoked continuously, before each and every Scenario. From the ‘callonce’ standpoint, I guess it is not correct, this is causing me to hit the authentication endpoint unnecessarily. I am using karate 0.3.1.

Best,

Neill

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ptrthomascommented, Apr 28, 2017

@neillfontes that looks perfect actually. I may actually modify the doc / examples along these lines !

1reaction
neillfontescommented, Apr 28, 2017

@ptrthomas. It worked fine now.

I’ve adopted the folder structure below. Any objections or recommendations? feature1 and feature2 call the common-whatever.feature in this case, and the cached callonce works well.

/
   /features 
       Runner.java
       /feature1
          feature1.feature
      /feature2
          feature2.feature
   /common
      common-whatever.feature
Read more comments on GitHub >

github_iconTop Results From Across the Web

Karate - callonce feature doesn't cache the response
1 Answer 1 ... It must be because you are using the IDE support / right-click / "run-as" option. This is an open...
Read more >
Prevent loop when callonce is calling itself #1669 - GitHub
I'm working with karate-1.0.1.jar and calling it as follows: java -jar karate-1.0.1.jar -C -T 1 my.feature Not sure if I found a bug...
Read more >
karate.callSingle() feature in Karate Framework| Part 14
This video talks about the Karate Hooks concept - karate.
Read more >
Karate Demo - GitHub Pages
Shows how to dynamically create a JSON array and then use it to call a *.feature file in a loop. In this example,...
Read more >
std::call_once - cppreference.com
If concurrent calls to call_once pass different functions f , it is unspecified which f will be called. The selected function runs in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found