Cucumber
Introduction
Cucumber is a testing framework that helps to bridge the gap between QA and business managers. Tests are written in plain language terms using Gherkin so anyone in the team can understand even if they are not a technical person, with the help of feature files which we create to run the tests, also we can run multiple scenarios in one feature file. Cucumber interprets the tests into the specified programming language and using Selenium to drive the test cases in a browser.
Installation / Dependencies
Cucumber Eclipse Feature need to be installed, to create Feature Stories:
Follow instructions:
- Eclipses is already open
- Click on ‘Help’ Button/Tab
- Click on ‘Install new Software…’ Button
- Click on ‘Add’ Button
– Under ‘Name’ type in ‘Cucumber’
– Under ‘Location’ type in ‘http://cucumber.github.com/cucumber-eclipse/update-site’ - Click on ‘Ok’ Button
- Select Cucumber in Field, keep clicking ‘Next’ until Completed, followed by ‘Finish’ Button
Pro’s And Con’s
Setup With Examples
– Cucumber Structure
– Cucumber Framework
o Feature File
♣ Creating a Feature File
♣ Right Click on your Feature Folder
♣ Under ‘File Name’ type in your Feature Name with .feature at the end
♣ Click on ‘Finish’ Button (A Feature File would be generated)
Notes:
- @Tag – used within TestRunner.Class to execute that Particular Scenario or a Group of Scenarios.
- Scenario: – used to create a single Scenario.
- Scenario Outline: with Examples: – used for a single Scenario that’s executed multiple times.
- Highlighted Yellow – that means no Method/Code has been created and aligned to it.
– TestRunner.Class
♣ Used to Execute Chosen Scenarios / Test Scripts
Notes:
- Feature – location of created Feature Files
- Tags – executes Scenario related to Tag(s) listed
o Single Scenario – “@tag1”
o Multiple Scenario – “@tag1, @tag2”
o Execute all, but exclude this Scenario – “~@tag3”
- Glue – location for created stepdefinitions
- dryRun – true = compiles code to check for Errors, false = Execute functional Scripts
- format – Cucumber generated Reports
o StepDefinition.Class
♣ Using the TestRunner.Class, execute it via the DryRun as True, this would generate the following:
♣ Copy these Scenario Methods from the Console and add them into your StepDefinition.Class
- Please Note that these Scenario Methods must be UNIQUE, otherwise Cucumber wouldn’t know which to Execute
♣ Add Code into each Method, to create a full Test
♣ For the drivers to be linked together with the Hook.Class & StepDefinition.Class, you need to add the following into the StepDefinition.Class (As the Webdriver gets initialised in the Hook.Class firstly, it needs to carry over to the StepDefinition.Class).
- Hook.class
♣ @Before – executes the Website with chosen Browser
♣ @After – executes screenshots for Pass / Fail into Report
The CucumberReportStep.Class is below:
- Cucumber Reporting
– Custom Extent Reporting
♣ I’ve added this within the TestRunner.Class along with the Config
♣ Config.xml (can be found on Extent Report Website)
Reference Sites
– http://extentreports.relevantcodes.com/java/#configuration
– http://toolsqa.wpengine.com/cucumber/gherkin-keywords/
– http://toolsqa.com/cucumber/cucumber-tutorial/
– https://github.com/email2vimalraj/CucumberExtentReporter
Latest content
-
My first Regional Scrum Gathering in Stockholm – key takeaways
Published on: 30 October, 2024 -
Transformation Day – How do you fit a square peg in a round hole?
Published on: 29 October, 2024 -
How product management improves public sector digital services
Published on: 26 September, 2024 -
How a business analyst brings value to agile delivery in the public sector
Published on: 4 September, 2024