Cucumber is a testing framework which supports Behaviour Driven Development (BDD) which is used to write acceptance tests for web application. It allows automation of functional validation in easily readable and understandable format (like plain English) to Business Analysts, Developers, Testers, etc.
Cucumber was implemented in Ruby and then extended to Java framework. It supports to jUnit. Behavior Driven Development is extension of Test Driven Development.
Cucumber Basic:
1-Feature files
2-Feature
3- Sceanarios
4-jUnit runner
1-Feature files:Feature files are the important part of cucumber which is used to write the automation script.These files can be used as a documents.Feature file saves as a .feature extension.
test.feature
Feature: about Scala developer
In order to get a high paid job
As a Scala developer
I want to learn Scala development
Scenario: I am a Scala developer.
Given I am a Scala developer
When I apply for a job
Then I got less paid job
And I am not satisfied for this salary
But My parents is still satisfied
2-Feature: This part gives the information of high level of business requirement.Description of feature is very short.
3-Scenario: Scenario defined the particular functionality which is under test.In scenarios we used different annotation.
@Given
@When
@Then
@And
@But
4-JunitRunner:For running the feature file cucumber used Junit runner.
For running the cucumber you have to add cucumber jar files in your project.
Here is the code:
test.feature
Feature: about Scala developer
In order to get a high paid job
As a Scala developer
I want to learn Scala development
Scenario: I am a java developer.
Given I am a “java” developer
When I apply for a job
Then I got less paid job
And I am not satisfied for this salary
But My parents is still satisfied
Scenario: I am a “Scala” developer.
Given I am a “Scala” developer
When I apply for a job
Then I got “high” paid job
And I am “highly” satisfied for this salary
But My parents is “highly” satisfied
now we make a java file.
tester.java
We can easily see the html report created by cucumber.