Thursday, 3 August 2017

What is BDD and How to implement using Cucumber ?


Cucumber
  • A testing framework which supports BDD.
  • Define your application behavior in plain english language.
    • Grammer is defined by Gherkin langauge


Challenges with TDD 
Normally, developers develops features but write test code later. Due to need of release, he does quick but inefficient testing.  
Test-cases focus on the functionality of its integration.


BDD
  • Takes care of workflow in place of functionality.
  • Application is designed by describing its behavior for outside observer.
  • Behavior is written in readable and understandable language.
  • Behavior is defined in Given-When-Then steps.

Gherkin
Business-readable domain specific language
Understandable for BA, testers and customer perspective
Allows creating precise acceptance criteria

Example
Scenario: Eat 5 out of 12 
Given there are 12 cucumbers 
When I eat 5 cucumbers
Then I should have 7 cucumbers 




Feature file
consists following components :  
1. Feature: Description of the current test script which has to be executed.
2. Scenario: Description of the steps and expected outcome for a particular test case.
3. Scenario Outline: Same scenario can be executed for multiple sets of data using scenario outline. The data is provided by a tabular structure separated by |
4. Given: Context of the text to be executed. By using data tables "Given", step can also be parameterized.
5. When: Test action that has to performed
6. Then: Expected outcome of the test can be represented by "Then"




STEP DEFINITION
It maps the test case steps in the feature files (introduced by Given/When/Then) to code, which executes and checks the outcomes from the system under test.












No comments:

Post a Comment

Note: only a member of this blog may post a comment.