In Cucumber, is it possible to programmatically get the current step being executed?

后端 未结 11 2446
清歌不尽
清歌不尽 2020-12-04 00:22
Scenario: As a user, I want to login to the system
Given I am on my website
When I enter valid credentials
Then I am taken to the home page

The sce

11条回答
  •  有刺的猬
    2020-12-04 01:05

    Being a newbie m not allowed to comment so here is some info, assuming you are using cucumber-jvm.

    Short answer, No, Cucumber by itself doesnt have the option to read step names. You could use the method names to identify what was called.

    Also, @BEFORE STEP / @AFTER STEP tags are not yet available so you will have to define the call for each step.

    https://github.com/cucumber/cucumber-jvm/pull/838#issuecomment-234110573

    or the testing framework like junit or testng could let you access the execution details - something like this: http://junit.org/junit4/javadoc/4.12/org/junit/rules/TestWatcher.html.

    And if you really need the step names only for reporting purposes, you can simply parse the xml report that the testing framework generates.

提交回复
热议问题