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.

Adding Fake Arguement Does Not Allow Callonce File to be Cached Twice

See original GitHub issue

When calling the same file twice using Callonce, adding a fake argument is supposed to cache the responses for each call, but instead the cache is being hit.

Feature: test set-up routines that run only once, similar to how @BeforeClass works

Background:

* url demoBaseUrl

* def firstCall = read('../callarray/kitten-create.feature')
* def secondCall = read('../callarray/kitten-create.feature')

* def firstResult = callonce firstCall kittens
* def secondResult = callonce secondCall kittens

Scenario Outline: various tests on the cats created

    Given path 'cats'
    When method get
    Then status 200
    And match response[*].name contains '<name>' 

Examples:
        | name |
        | Bob   |
        | Nyan |

The result is kitten-create.feature gets called for every line of the Examples table, instead of being cached and only called once.

Archive.zip

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
NuttBoxercommented, Nov 17, 2017

I figured out the solution, can’t believe I didn’t think of it sooner. I need to move the test when the file get’s called twice into a separate Scenario that runs first in the .feature file. Then I can use callonce in the scenario outline to prevent all over 100 unnecessary requests from running, and bloating the log with over 1,000 extra lines.

Allowing callonce to function dynamically depending on where it’s placed in a feature file is still a better approach, in my opinion, but you don’t seem interested in pursing that line of thought.

Appreciate your time in trying to help me solve this.

0reactions
ptrthomascommented, Nov 28, 2017

@NuttBoxer I just realized that if you were using the IDE “right-click and run-as” option to run tests in dev mode, callonce would NOT work at all. I always assumed that you were using the JUnit runner.

In case you were using the IDE, perhaps this has contributed to some of the miscommunication, apologies 😐

I just fixed this in dev, here’s the issue reference: https://github.com/intuit/karate/issues/136

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Fake Arguement Does Not Allow Callonce File to be ...
When calling the same file twice using Callonce, adding a fake argument is supposed to cache the responses for each call, but instead...
Read more >
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 >
Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
Cached response #. The problem. Let's inspect the interception object yielded by the cy.wait command. The interception does not the response ...
Read more >
Using .NET: Avoid Common Performance Pitfalls for Speedier ...
It will allow reflection to go down an optimized, more efficient code path that does not perform argument type-coercion. If the argument types ......
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