Simplifying??? How its simple to learn cucumber?
Yes it is, because its like "COOKING".
CUCUMBER - THE COOL GREEN ONE
Of Course we cook, we are in the kitchen and we want to create a new recipe with the available ingredients. Cucumber is like a cookbook that helps us to write down our own recipe with easy steps anyone can follow easily.Like the verse “Anyone can cook” i will say “Anyone can learn cucumber”.
First step in all cucumber project is to create a FEATURE file:
Right-click on the Project where feature files should be created.
From the context menu of the target directory, choose New | Gherkin feature file, and specify the filename. It should be with (.Feature) example. If you are creating a feature file for an Assignment module page it should be Assignment.feature. In eclipse the feature file will be created under src/test/resources. It will appear as a green flower (cucumber symbol).
In the feature file, type your scenario from gherin i.e. excel sheet. Gherkins are given, when, then format.
#Sample Feature Definition Template
@tag
Feature: Title of your feature
I want to use this template for my feature file
@tag1
Scenario: Title of your scenario
Given I want to write a step with precondition
And some other precondition
When I complete action
And some other action
And yet another action
Then I validate the outcomes
And check more outcomes
@tag2
Scenario Outline: Title of your scenario outline
Given I want to write a step with <name>
When I check for the <value> in step
Then I verify the <status> in step
Examples:
| name | value | status |
| name1 | 5 | success |
| name2 | 7 | Fail |
Now STEPS:
After creating the Feature file, next is step definition. Create a step definition under src/test/java. You can give any name as per the module. Once created it will appear as a java class. example AssignmentSD.java You need to run the feature file to get correct steps to write it in step definition .Copy paste it in corresponding SD files. Make sure you note down the failed/skipped and runtime to have the correct count of scenarios in each module. Make sure you import all given when and then by ctrl+Space :)
After this you need to decide as per requirements you will be following page Object Model or Page Factory Model. But whatever it is you need to have a Test runner, hooks,driver factory utilities etc
Hooks class:Cucumber’s Before hook is mainly responsible for initializing the driver and opening a web browser which is a prerequisite for all scenarios. Cucumber’s After hook is responsible for capturing a snapshot of failure and closing the browser.
If it is a Base class We need to create a Base class to maintain the page object classes.
Dependencies: Downloaded necessary dependencies for your project in POM.XML file.Make sure you comment/remove the unwanted dependencies sometimes it throws errors.
Here comes the REPORT
Cucumber: Cucumber reports have information about Test scenarios that have passed or failed. It explains the behavior of software systems using plain simple English.
Extent: Extent Reports is an open-source reporting library used in selenium test automation. Extent reports become the first choice of Selenium Automation Testers, even though Selenium comes with inbuilt reports using frameworks like JUnit and TestNG.These reports are HTML documents that depict results as pie charts,pdf report etc
Allure : Allure is an open source framework that is open source designed to create interactive and comprehensive test report.
It is a reporting framework that represents brief reports in clear form
Pretty Format(HTML Report): Pretty Format generates the Cucumber test report in the HTML format, i.e. an HTML file. It is the most readable report format. It generates the report in the same way as it is a feature file so it becomes easy to track the test results
JSon:JavaScript Object Notation (JSON)-report contains metadata of the session, a summary, collectors, tests and warnings. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa).
Now JENKINS:
Jenkins is a tool used for Continuous Integration. It is an open-source tool written in Java. It helps to automate all the tasks related to building, testing, and deploying the code from a shared repository and integrating project changes.
It is compatible with many open-source plugins and tools such as Maven. we can create an allure report in jenkins. we can see our console output in jenkins.We can also generate allure reports through jenkins. This is the graphical format
What is a GIT:
Git: GIt is a free and open source distributed version control system design to handle projects with speed and efficiency.GitHub is a code hosting platform for version control and collaboration
Git lets us see the entire timeline of the changes, decisions, and progression of a project in one place by creating an account in git, adding a git repository after that we havepush the code through the git for running the program through jenkins .
GitHub hosts Git repositories and provides tools to ship better code through command line features, issues pull requests and code review.
Hope you all made a note of all the above ingredients , cook and serve your wonderful project.
BTW This is my first post. If it is simple and easy to understand please support me for my next:)
********************************************************************************************************
Enjoy Cooking! Be a cool CUCUMBER and Learn happily.
********************************************************************************************************