In
behavior driven development, both developer and stakeholder can write automated
test cases. Based on the documented test cases, stakeholder confirms the
behavior that he is expecting from the application. Since these test cases are
considered as acceptance criteria to release a product/application, these are
termed as acceptance tests.
How acceptance tests
are different from unit tests?
Unit
tests are completely driven by the developer to make sure everything is working
fine. Whereas acceptance tests are documented by developer and stakeholders to
make sure that you are building the right thing.
a. Domain experts may
not be technical and technical experts may not have complete domain knowledge.
So, we need a way to establish proper communication between domain expert and
technical user.
b. The requirements
provided by the domain expert can be in abstract form. It is difficult to the
technical user to understand.
Why Cucumber?
Cucumber
fills the gap between developers and stake holders. By using cucumber, all the
stakeholders can be involved in writing test cases. Test cases are written in
general (like English, French etc.,) language, that is understandable by
stakeholders. These test cases are mapped to the actual test code developed by
technical users.
Better
communication should be established between stake holders and developers to get
rid of misunderstandings.
Stakeholders/developers
write the acceptance test cases in .feature file. A feature file is a
collection of scenarios, where each scenario targets an independent use case.
Login.feature
Feature: Login Login should be quick and friendly. Scenario: Successful Login Users should be logged in successfully by providing correct username and password. Given I have chosen to Login When I log in with correct user name and password Then I should be logged in successfully And I should see a personalized greeting message Scenario: Login failed with wrong user name and correct password User log in should fail on wrong user name Given I have chosen to Login When I log in with wrong user name and correct password Then I should not be logged in And I should see an error message Scenario: Login failed with correct user name and wrong password User log in should fail on wrong password Given I have chosen to Login When I log in with correct user name and wrong password Then I should not be logged in And I should see an error message
As
you see, Login.feature contains the test scenarios to be tested against login
module of the application. The statements in the ‘.feature’ file are written
using Gherkin rules. For example, Feature, Scenario, Given, When, Then, And are
the terms in Gherkin language. Cucumber process these terms separately.
How cucumber works?
a. Stakeholders write
the scenarios in a feature file.
b. When you ran
cucumber, it reads the feature file and parse the scenarios to test.
c. After parsing the scenarios,
it runs each scenario against the application.
Note
Scenario
is a collection of steps
Feature
is a collection of scenarios
No comments:
Post a Comment