How to get name of scenario in cucumber java?

后端 未结 4 1562
予麋鹿
予麋鹿 2020-12-16 10:31

I would like to get name of scenario to have meaningful logs and to generate custom report at run-time in java. Scenario class have only has getStatus() and getSourceTagName

4条回答
  •  温柔的废话
    2020-12-16 11:30

    From version 1.6, in addition to, getStatus() and getSourceTagNames(), there is another method, getName() that returns the scenario's description. For example, for a scenario as follows:

    Scenario: verify number of topics shown in the UI
    

    scenario.getName() returns "verify number of topics shown in the UI"

    I initialize scenario in @Before as follows:

    @Before
    public void before(Scenario scenario) {
        this.scenario = scenario;
    }
    

    Hope this helps.

提交回复
热议问题