Search code examples
javaseleniumjunitcucumberselenide

Cucumber reports values inside code


Is there some way to get these cucumber report values inside code in some variables?

For example:

int scenariosRun = cucumber.getScenarios(); // 8
int scenariosPassed = cucumber.getScenariosPassed(); // 8

enter image description here


Solution

  • Yes, you can get current scenario details in the after/before hook as given below,

    @Before
    public void before(Scenario scenario) {
        System.out.println("------------------------------");
        System.out.println("Starting - " + scenario.getName());
        System.out.println("------------------------------");
    }
    
    @After
    public void before(Scenario scenario) {
        System.out.println("------------------------------");
        System.out.println(scenario.getName() + " Status - " + scenario.getStatus());
        System.out.println("------------------------------");
    }