Home > Back-end >  Karate - is there any way to fetch name of current feature file
Karate - is there any way to fetch name of current feature file

Time:06-13

I want to make a simple adjustment to the feature file below:

@Read @healthCheck
Feature: healthCheck
  Background:
    * def service = "healthCheck"
    * def req = call read("classpath:SoapRequest.feature")

  Scenario: toggle healthcheck
    Given match each /Envelope/Body/pingResponse/healthChecks/healthCheck/status == "SUCCESS"

to something like:

@Read @healthCheck
Feature: healthCheck
  Background:
    * def service = //name of this feature
    * def req = call read("classpath:SoapRequest.feature")

  Scenario: toggle healthcheck
    Given match each /Envelope/Body/pingResponse/healthChecks/healthCheck/status == "SUCCESS"

to avoid mistakes of duplicate input, is there any related usages?

CodePudding user response:

See if this works:

* def service = karate.feature.fileName

Refer: https://github.com/karatelabs/karate/wiki/1.0-upgrade-guide#karateinfo-deprecated

If it doesn't work, you may have to contribute code.

  • Related