8. Keyword “Examples” and conclusion

 

Gherkin keyword: Examples

Cucumber provides another useful Gherkin keyword which is used scenario parametrization. A scenario with an “Example” keyword will be executed multiple times with different parameters. Here is an instance:

@init @logout
  Scenario Outline: Successful Login with Valid Credentials
    Given User is on Home Page
    When User Navigate to LogIn Page
    And User enters username "<userName>"
    And User enters password "<password>"
    And Click login
    Then Message displayed Login Successfully

 
Examples:
| userName | password |
| username1 | password 1 |
| invalid | invalid |

To add parameters for test steps we need to add the parameter’s name between “<” and “>”. The parameter values should be added to the implemented scenario in a “table”. The first row of the table is reserved for the name of the parameters. The Example keyword will allow parameterization just with primitive types (strings and numbers).

 

Conclusion

 

The idea of Cucumber is really good, but if we want to apply it to web testing with Selenium comparing it with the usual TestNG or JUnit approach, we are losing too much.
 

    Here are cons using Cucumber in web testing:

  • Multiple before and after methods in different levels of hierarchy
  • Simple page flow between test steps

 

    Pros using Cucumber in web testing:

  • Spend less time with writing documentations of the test cases

 
Used literature and useful tutorials:
http://zsoltfabok.com/blog/2011/12/cucumber-jvm-preparation/
http://zsoltfabok.com/blog/2011/12/cucumber-jvm-more-scenarios/
http://zsoltfabok.com/blog/2012/01/cucumber-jvm-di/
http://zsoltfabok.com/blog/2012/03/cucumber-jvm-mocking/
http://zsoltfabok.com/blog/2012/09/cucumber-jvm-web-with-spring-mvc/
http://zsoltfabok.com/blog/2012/09/cucumber-jvm-hooks/
https://cucumber.io/blog/2015/07/08/polymorphic-step-definitions
http://picocontainer.com/introduction.html
http://www.relishapp.com/cucumber/cucumber/docs
https://github.com/cucumber/cucumber/wiki/A-Table-Of-Content
http://toolsqa.com/cucumber/cucumber-tutorial/
https://hjrlive.wordpress.com/2014/02/15/test-post/

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>