CucumberJVM: 03 - CucumberOptions

Test Runner Cucumber Options

 

dryRun

true = Validate the Cucumber Feature, Definition & Runner wiring

false = execute Definition logic

 

Features

 

Glue

 

Tags

 

Monochrome

=true

Feature: Free CRM Login Feature
Starting ChromeDriver 2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9) on port 17858
Only local connections are allowed.
Jun 12, 2018 3:28:10 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Free CRM software in the cloud powers sales and customer service
HomePage title is :CRMPRO

  Scenario: Free CRM Login Test Scenario   # src/main/java/Features/login.feature:3
    Given user is already on Login Page    # LoginStepDefinition.user_is_already_on_Login_Page()
    When title of login page is Free CRM   # LoginStepDefinition.title_of_login_page_is_Free_CRM()
    Then user enters username and password # LoginStepDefinition.user_enters_username_and_password()
    Then user clicks on login button       # LoginStepDefinition.user_clicks_on_login_button()
    And user is on the home page           # LoginStepDefinition.user_is_on_the_home_page()
    Then close the browser                 # LoginStepDefinition.close_the_browser()
      java.lang.AssertionError
          at org.junit.Assert.fail(Assert.java:86)
          at org.junit.Assert.assertTrue(Assert.java:41)
          at org.junit.Assert.assertTrue(Assert.java:52)
          at stepDefinitions.LoginStepDefinition.close_the_browser(LoginStepDefinition.java:63)
          at ?.Then close the browser(src/main/java/Features/login.feature:11)

Failed scenarios:
src/main/java/Features/login.feature:3 # Scenario: Free CRM Login Test Scenario

1 Scenarios (1 failed)
6 Steps (1 failed, 5 passed)
0m7.781s

java.lang.AssertionError
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertTrue(Assert.java:52)
    at stepDefinitions.LoginStepDefinition.close_the_browser(LoginStepDefinition.java:63)
    at ?.Then close the browser(src/main/java/Features/login.feature:11)

 

=false

Feature: Free CRM Login Feature
Starting ChromeDriver 2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9) on port 24639
Only local connections are allowed.
Jun 12, 2018 3:27:26 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Free CRM software in the cloud powers sales and customer service
HomePage title is :CRMPRO

  Scenario: Free CRM Login Test Scenario   # src/main/java/Features/login.feature:3
    Given user is already on Login Page    # LoginStepDefinition.user_is_already_on_Login_Page()
    When title of login page is Free CRM   # LoginStepDefinition.title_of_login_page_is_Free_CRM()
    Then user enters username and password # LoginStepDefinition.user_enters_username_and_password()
    Then user clicks on login button       # LoginStepDefinition.user_clicks_on_login_button()
    And user is on the home page           # LoginStepDefinition.user_is_on_the_home_page()
    Then close the browser                 # LoginStepDefinition.close_the_browser()
      java.lang.AssertionError
          at org.junit.Assert.fail(Assert.java:86)
          at org.junit.Assert.assertTrue(Assert.java:41)
          at org.junit.Assert.assertTrue(Assert.java:52)
          at stepDefinitions.LoginStepDefinition.close_the_browser(LoginStepDefinition.java:63)
          at ?.Then close the browser(src/main/java/Features/login.feature:11)
      

Failed scenarios:
src/main/java/Features/login.feature:3 # Scenario: Free CRM Login Test Scenario

1 Scenarios (1 failed)
6 Steps (1 failed, 5 passed)
0m8.077s

java.lang.AssertionError
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertTrue(Assert.java:52)
    at stepDefinitions.LoginStepDefinition.close_the_browser(LoginStepDefinition.java:63)
    at ?.Then close the browser(src/main/java/Features/login.feature:11)

Format

 

strict

 

 


CucumberOptions JavaDoc

 

    • Element Detail

      • dryRun

        public abstract boolean dryRun
        Returns:
        true if this is a dry run
        Default:
        false
      • strict

        public abstract boolean strict
        Returns:
        true if strict mode is enabled (fail if there are undefined or pending steps)
        Default:
        false
      • features

        public abstract String[] features
        Returns:
        the paths to the feature(s)
        Default:
        {}
      • glue

        public abstract String[] glue
        Returns:
        where to look for glue code (stepdefs and hooks)
        Default:
        {}
      • tags

        public abstract String[] tags
        Returns:
        what tags in the features should be executed
        Default:
        {}
      • format

        @Deprecated
        public abstract String[] format
        Deprecated. use plugin()
        Returns:
        what formatter(s) to use
        Default:
        {}
      • plugin

        public abstract String[] plugin
        Returns:
        what plugins(s) to use
        Default:
        {}
      • monochrome

        public abstract boolean monochrome
        Returns:
        whether or not to use monochrome output
        Default:
        false
      • name

        public abstract String[] name
        Specify a patternfilter for features or scenarios
        Returns:
        a list of patterns
        Default:
        {}
      • snippets

        public abstract SnippetType snippets
        Returns:
        what format should the snippets use. underscore, camelcase
        Default:
        cucumber.api.SnippetType.UNDERSCORE
      • junit

        public abstract String[] junit
        Returns:
        the options for the JUnit runner
        Default:
        {}

json Output

  • json:json-output/cucumber.json
[
  {
    "line": 1,
    "elements": [
      {
        "line": 3,
        "name": "Free CRM Login Test Scenario",
        "description": "",
        "id": "free-crm-login-feature;free-crm-login-test-scenario",
        "type": "scenario",
        "keyword": "Scenario",
        "steps": [
          {
            "result": {
              "duration": 4846607341,
              "status": "passed"
            },
            "line": 5,
            "name": "user is already on Login Page",
            "match": {
              "location": "LoginStepDefinition.user_is_already_on_Login_Page()"
            },
            "keyword": "Given "
          },
          {
            "result": {
              "duration": 52007819,
              "status": "passed"
            },
            "line": 6,
            "name": "title of login page is Free CRM",
            "match": {
              "location": "LoginStepDefinition.title_of_login_page_is_Free_CRM()"
            },
            "keyword": "When "
          },
          {
            "result": {
              "duration": 1100417407,
              "status": "passed"
            },
            "line": 7,
            "name": "user enters username and password",
            "match": {
              "location": "LoginStepDefinition.user_enters_username_and_password()"
            },
            "keyword": "Then "
          },
          {
            "result": {
              "duration": 1999782392,
              "status": "passed"
            },
            "line": 8,
            "name": "user clicks on login button",
            "match": {
              "location": "LoginStepDefinition.user_clicks_on_login_button()"
            },
            "keyword": "Then "
          },
          {
            "result": {
              "duration": 593424951,
              "status": "passed"
            },
            "line": 9,
            "name": "user is on the home page",
            "match": {
              "location": "LoginStepDefinition.user_is_on_the_home_page()"
            },
            "keyword": "And "
          },
          {
            "result": {
              "duration": 24635,
              "status": "passed"
            },
            "line": 11,
            "name": "close the browser",
            "match": {
              "location": "LoginStepDefinition.close_the_browser()"
            },
            "keyword": "Then "
          }
        ]
      }
    ],
    "name": "Free CRM Login Feature",
    "description": "",
    "id": "free-crm-login-feature",
    "keyword": "Feature",
    "uri": "src/main/java/Features/login.feature"
  }
]

jUnit XML

junit: junit-xml-output

<?xml version="1.0" encoding="UTF-8"?><testsuite failures="0" name="cucumber.runtime.formatter.JUnitFormatter" skipped="0" tests="1" time="8.357252">
<testcase classname="Free CRM Login Feature" name="Free CRM Login Test Scenario" time="8.357252">
<system-out><![CDATA[Given user is already on Login Page.........................................passed
When title of login page is Free CRM........................................passed
Then user enters username and password......................................passed
Then user clicks on login button............................................passed
And user is on the home page................................................passed
Then close the browser......................................................passed
]]></system-out>
</testcase>
</testsuite>

strict

  • if any step is missing, the entire suite fails
  • different from assert fail
  • best to leave as =true UNLESS actively developing

=true

Feature: Free CRM Login Feature
Starting ChromeDriver 2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9) on port 18304
Only local connections are allowed.
Jun 12, 2018 3:45:59 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Free CRM software in the cloud powers sales and customer service
HomePage title is :CRMPRO

  Scenario: Free CRM Login Test Scenario   # src/main/java/Features/login.feature:3
    Given user is already on Login Page    # LoginStepDefinition.user_is_already_on_Login_Page()
    When title of login page is Free CRM   # LoginStepDefinition.title_of_login_page_is_Free_CRM()
    Then user enters username and password # LoginStepDefinition.user_enters_username_and_password()
    Then user clicks on login button       # LoginStepDefinition.user_clicks_on_login_button()
    And user is on the home page           # LoginStepDefinition.user_is_on_the_home_page()
    Then close the browser

Undefined scenarios:
src/main/java/Features/login.feature:3 # Scenario: Free CRM Login Test Scenario

1 Scenarios (1 undefined)
6 Steps (1 undefined, 5 passed)
0m9.331s

You can implement missing steps with the snippets below:

@Then("^close the browser$")
public void close_the_browser() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

 

=false

  • when strict=false, jUnit will not report the missing step as a FAIL
Feature: Free CRM Login Feature
Starting ChromeDriver 2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9) on port 11242
Only local connections are allowed.
Jun 12, 2018 3:47:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Free CRM software in the cloud powers sales and customer service
HomePage title is :CRMPRO

  Scenario: Free CRM Login Test Scenario   # src/main/java/Features/login.feature:3
    Given user is already on Login Page    # LoginStepDefinition.user_is_already_on_Login_Page()
    When title of login page is Free CRM   # LoginStepDefinition.title_of_login_page_is_Free_CRM()
    Then user enters username and password # LoginStepDefinition.user_enters_username_and_password()
    Then user clicks on login button       # LoginStepDefinition.user_clicks_on_login_button()
    And user is on the home page           # LoginStepDefinition.user_is_on_the_home_page()
    Then close the browser

1 Scenarios (1 undefined)
6 Steps (1 undefined, 5 passed)
0m9.597s

You can implement missing steps with the snippets below:

@Then("^close the browser$")
public void close_the_browser() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}