1 / 19

Integrating Cucumber with Selenium

Integrating Cucumber with Selenium. Puscasu Dragos 13.02.2014. There is an A for everything. What is Cucumber What is BDD. Best Practices. Cucumber Feature Integration with Selenium. Examples. Behaviour-Driven Development – BDD.

hall
Télécharger la présentation

Integrating Cucumber with Selenium

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Integrating Cucumber with Selenium Puscasu Dragos 13.02.2014

  2. There is an A for everything • What is Cucumber • What is BDD • Best Practices • Cucumber Feature • Integration with Selenium • Examples

  3. Behaviour-Driven Development – BDD • Software development process based on test-driven development (TDD) • Evolved out of established agile practices • Brings focus through concept of business value • What’s the next most important thing the system doesn’t do? • Consistent vocabulary - eliminating some of the ambiguity and miscommunication that occur when technical people talk to business people • Everyone speaks the same LANGUAGE • Story template : • As a [X= person or role that will benefit] I want [Y= some feature] so that [Z= benefit or value of the feature]

  4. Cucumber – Language:Gherkin • Feature: Some descriptive text of what is desired • In order to realize a named business value • As an explicit system actor • I want to gain some beneficial outcome which furthers the goal • Scenario: Some determinable business situation • Given some precondition • When some action by the actor • Then some testable outcome is achieved • And something else we can check happens too

  5. Cucumber – Features • “Feature: … ” – start feature, provide title • “In order to… As a… I want to…” – provide context to readers, not parsed in order to match a definition • “Scenario: … ” – start scenario, provide scenario description • Given/When/Then/And/But – steps of the scenarios, matched by a regular expression (defined elsewhere) • Feature file (*.feature) – consists of one feature • A feature • Every ”sentence” is considered as a step which needs to be implemented • Contains a list of scenarios • May contain “Scenario outline” • May contain “Background”

  6. Cucumber – Features • “Scenario: …” keyword – optional title • A scenario has one ore more Steps • “Scenario Outline:…” - express through the use of a template with placeholders: • Scenario Outline: Eating • Given there are <start> cucumbers • When I eat <eat> cucumbers • Then I should have <left> cucumbers • Examples: • | start | eat | left | • | 12 | 5 | 7 | • | 20 | 5 | 15 | • Run once for each row in the Examples section - placeholders take the real value from the Examples: table row

  7. Cucumber – Features • Add context to scenarios(Background) Feature: Access to a site Background: Given that I open the application in Internet Explorer And I am logged in And I have admin rights Scenario: Delete a music video from the application in Internet Explorer Given I go to video management screen When I delete video number 25 Then Video 25 is no longer displayed in the video management screen

  8. Cucumber – Features public class StepDefinition{ @Given("^I have an instance of my class$") public void I_have_an_instance_of_my_class() { } @When("^I call my method with \"([^\"]*)\"$") public void I_call_my_method_with_(String arg1) { } @Then("^I receive \"([^\"]*)\"$") public void I_receive_(String arg1) { } }

  9. Cucumber – Features • Tags - organize your features and scenarios: • @billing • Feature: Verify billing • @important • Scenario: Missing product description • Tags can be specified in @Cucumber.Options : • @Cucumber.Options ( • features = {“path_to_feature_files”}, • glue = {“path_to_step_definition_class”}, • tags = “@important”) / tags = “~@Smoke”)

  10. Cucumber – Features • Cucumber Reports: • Junit • HTML • JSON

  11. Integration with Selenium • <dependency> • <groupId>org.seleniumhq.selenium</groupId> • <artifactId>selenium-java</artifactId> • <version>2.39.0</version> • </dependency>

  12. Best practices #1 Write declarative features

  13. Best practices #2 • Insert a narrative • Feature: Some descriptive text of what is desired • In order to realize a named business value • As an explicit system actor • I want to gain some beneficial outcome which furthers the goal

  14. Best practices #3 Reuse step definitions

  15. Best practices #4 Avoid conjunctive steps

  16. Best practices #5 Use backgrounds wisely

  17. Read more • Presentation • http://www.slideshare.net/bmabey/writing-software-not-code-with-cucumber?from_search=3 • http://www.slideshare.net/rapaul/acceptance-tests?utm_source=slideshow&utm_medium=ssemail&utm_campaign=download_notification • http://alkesh.github.io/iprug-cucumber-presentation/#1 • Article/Blog • http://dannorth.net/introducing-bdd/ • http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/ • http://cukes.info/step-definitions.html • http://zsoltfabok.com/blog/2012/09/cucumber-jvm-web-with-spring-mvc/ • http://docs.behat.org/guides/1.gherkin.html

  18. Thank You Puscasu Dragos Senior Software Tester

More Related