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:
- 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)
- @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.
♣ Used to Execute Chosen Scenarios / Test Scripts
- 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
♣ 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).
♣ @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)
What we learned from Digital Government 2023Published on: 1 June, 2023
“The consulting industry has infantilised government”- how do we bridge the digital skills gap?Published on: 30 May, 2023
Addressing the barrier to efficiency — tackling government’s legacy systemsPublished on: 16 May, 2023
What are the barriers for SMEs when bidding for government contracts?Published on: 5 May, 2023