How to get name of scenario in cucumber java?

后端 未结 4 1567
予麋鹿
予麋鹿 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条回答
  •  旧时难觅i
    2020-12-16 11:23

    Below is the entire code for the problem asked, to save your time:

    import io.cucumber.java.Before;
    import io.cucumber.java.Scenario;
    Scenario scenario;
    
       @Before
        public void before(Scenario scenario) {
            this.scenario = scenario;
        }
    
        @Given("I test scenario name")
        public void test() {
            System.out.println(scenario.getName());
        }
    

提交回复
热议问题