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

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

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.