email2vimalraj / CucumberExtentReporter

A plugin to generate the cucumber jvm custom html report using ExtentsReport
http://www.vimalselvam.com/cucumber-extent-reporter/
MIT License
58 stars 75 forks source link

[question] Know step type? #13

Closed anshooarora closed 8 years ago

anshooarora commented 8 years ago

Hi Vimal

The next major version of Extent will have specific features to integrate with BDD. I wanted to ask you if there is a way with Cucumber to know the type of step that ran? For example:

Given x
When y
Then z
And zz

At runtime, is there a way to know if the step is Given, When, Then or And?

email2vimalraj commented 8 years ago

@anshooarora : Yes there is a way to get that information in Cucumber by using step.getKeyword() through the listener.

And btw, could you please help me to understand the new features that we are getting in ExtentReports for BDD.

anshooarora commented 8 years ago

The API is not yet started for BDD users, as I am still working on a high level code design. Need to keep things as generic as possible so the style can be switched from BDD to standard without much code changes. I asked the above question because:

bdd

If you see the above image, I need a way to put the title of the step (in bold: Description, Scenario, Given, When, Then) as part of the test.

Creating a child test would be a single line of code in the next version:

test.createNode("Hello").info("hello");

So would like to use the same strategy to create tests for each structure/step of BDD/Cucumber. So, I was thinking of something like:

feature = extent.createTest("feature name", "feature title");
background = feature.createNode(BDDStructure.BACKGROUND, "background title");
scenario = feature.createNode(BDDStructure.SCENARIO, "scenario name", "scenario title");
given = scenario.createNode(BDDStep.GIVEN, "title").error(Throwable t);

It is a pretty huge redesign from code perspective but will require much less code to setup your normal or bdd tests.

What do you think?

email2vimalraj commented 8 years ago

It would be great if we achieve this level of modularity. Great idea.