2

I have a scenario. I have added a header in background section. Now all scenarios are using that header except 2 scenarios. How can I remove already added header from those scenarios?

Feature: Some test
  background:
    * url url
    * header foo = bar
    * payload = read('classpath:payload.json')

  Scenario:
    Given request payload.create
    # I want to remove **foo** header
    When method post
    Then status 201

Any solution?

1 Answers1

1

Sorry, there is no way to "undo" a header.

The best thing would be to move the "special" scenario into a new Feature - this is a quite legitimate thing to do.

Or you have to duplicate the usage of header in multiple Scenario-s, which also is a perfectly legitimate thing to do.

Keep in mind, Karate requires you to write very little code. And please read this: https://stackoverflow.com/a/54126724/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248