Introduction to Cucumber:
Cucumber is basically a framework which is used for testing the application where the testscripts are written in plain english language.Mostly it is used for Acceptance testing and Functional Testing. BDD(Behavior Driven Development) technique is used while writting testcases.
Advantages of Using it:
Following are some of the advantages of using cucumber framework over using simple selenium framework.
1.It is very easy to understand the testcases for anyone(e.g Developer,Tester and Stakeholders).
2.Anyone can write the test cases because it is written in plain english.
3.The Test cases are stored in a .feature file which can be used for documentation purpose for the project.No need to write extra document for the features.
4.One more and very important feature of using Cucumber is ,it allows heavy reuse of code.
Prerequisites:
1.One must have understanding on core java.
2.One must be comfortable with using Selenium WebDriver.
3.I am assuming the reader is well acquanted with using Maven.
Basically We need three things to run the project with Cucumber.Those are listed below
1.Feature Files where the test scripts are written in plain english.
2.Step Definitions java class files where code resides
3.One Runner class which is used to run the Junit test.
How the Feature File looks like:
This is a file with extension .feature and kept in the same package name where the Runner class is kept inside.e.g if you keep the Runner class in Steps package then you must keep the feature files in same package which is shown in the below image.
The language in which features are written in feature file is called gherkin.
How the Step Definition file looks like
This is also called a Step layer.Here definitions for all steps are provided.
How the Runner class looks like
It is used to read the cucumber feature files and accordingly step definitions files are invoked. Here you can mention Format of the report in which you want ,I mean whether you want it in html format or json format,you can mention that.Also testcases can be tagged to run the same by skipping all other testcases which are written in the feature file.
How Feature file looks like using tags:
Installation of Cucumber:
There is no such .exe file or anything needed to work with Cucumber.One thing you have to do is that you have to add a couple of dependencies in your pom.xml file inside the maven project.That's all what needed to work with cucumber.Mainly Cucumber-java,cucumber-junit,gherkin dependencies need to be added through pom.xml file.
How those dependencies look like:
Once those dependencies are added,now you are ready to work with Cucumber.
One more extra addon on eclipse can be used for Cucumber to write the feature files which helps to signifies each and every properties of cucumber.
This can be added from eclipse >>Help>>Install new software by adding the text "Cucumber - http://cucumber.github.com/cucumber-eclipse/update-site" in Work With filed and clicking on Add button.
This is the very brief description about getting started with Cucumber.Thanks for reading it.