Tuesday, December 22, 2015

Different Option On Cucumber JUnit Runner

We can use different option of Cucumber-JVM JUnit runner using @CucumberOption annotation.

There are so many option available with @CucumberOption annotation.We will discuss in details below :

features : This is the most important part of the cucumber option.It is used to mention the path of the feature files like features ={"./sample.feature"} or mention the only folder of feature file, cucumber automatically get all the feature file in the mentioned path.

glue : This is the another most important part of the cucumber option.It is used to mention the path of the glue code files like glue ={"com/automation/steps"}. Cucumber automatically get all the glue codecorrespondng to the feature file.

snippets : This is used when we try to generate basic code structure with the different syntax style(like camelcase or underscore) from the feature file. We use this option in JUnit runner and run this file, after running this we get the basic method structure for the particular feature file on console of the editor. Syntax looks like this : snippets= SnippetType.CAMELCASE
 

monochrome : It is used to get the better result on console of the editor. Syntax is monochrome = true
 

plugin : It is another most important part of the Cucumber JVM runner option. It is used to generate different type of reporting style. We get html report json report xml report and many more type of report. Syntax is describe below:

        plugin = {
                "html:target/cucumber-html-report",
                "json:target/cucumber.json",
                "pretty:target/cucumber-pretty.txt",
                "usage:target/cucumber-usage.json",
                "junit:target/cucumber-results.xml",
                "progress:target/cucumber-progress.txt"
        }


dryRun : It is used to verify that all steps of the feature file defined on step generator or glue code file or not. Syntax is : dryRun= true
One thing keep in mind that when dryRun=true then entire code should not run only it checks that all the methods matched with feature file or not.  

strict: It is used to verify that all steps of the feature file defined on step generator or glue code file or not.
Syntax is : strict= true
Difference between dryRun and strict is that strict run allow execute the code and report as fail if any steps not implemented on feature code.

tags : It is a another option on Cucumber-JVM JUnit runner by which we can execute mentioned tags Syntax is : tags={"@tag1}.This tag should be mentioned on feature file like 
Feature: This is a sample feature file
@tag1
    Scenario: This is a scenario for Adding two number.
        Given Two number as 1 and 6
        When We add this two given number
        Then Sum Result should be 7


 We will discuss details on later post about this.

So after implement all the details runner class @CucumberOption should be looked like this :

@CucumberOptions(
        plugin = {
                "html:target/cucumber-html-report",
                "json:target/cucumber.json",
                "pretty:target/cucumber-pretty.txt",
                "usage:target/cucumber-usage.json",
                "junit:target/cucumber-results.xml",
                "progress:target/cucumber-progress.txt"
        },features ={"./sample.feature"},
            glue ={"com/automation/steps"},strict = true,
            dryRun= false,monochrome = true, snippets= SnippetType.CAMELCASE,tags={"@tag1"})

1 comment: