What Is BDD

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Jai Chowdary Gogineni

Ref:The RSpec Book-David Chelimsky

How BDD coming to the rescue


what is automatedacceptance Test ?
. The idea of automatedacceptance tests originates in eXtreme 1 Programming (XP), specically in the practice of Test-Driven (TDD). ! Instead of a business stakeholder passing their requirements to the develop- ment team without much opportunity for feedback, the developer and stake- holder collaborate to write automated tests that express the outcome that the stakeholder wants.

oo

what is TDD

I N E ! N I ! ! G O G!
KENT BECK 2003

In TDD, test cases are written before the code itself; at that point, they are unpassable (red). Code is written specically to pass a given test case. When the written code successfully passes the test (green), the passing code is refactored into a more elegant module without introducing any new functional elements. Known as redgreen-refractor, this whole process is the mantra of TDD

Advantages Of TDD?

Maintainable, Flexible, Easily Extensible

Why should we use BDD Approach instead of TDD


Automated tests are a good driving the design is even better for software development. First it suggests we need to understand the world from the point of view of our stake- holders if we are to deliver anything useful. We need to understand their domain. We use techniques from DomainDriven Design to help with this. The analyst helps the stake- holder articulate the requirement in terms of features that make sense to the stakeholder The acronym SMART is used to describe outcomes or objectives that have certain characteristics, namely, that they are: S-specic : means there is enough detail to know that something is done. M-measurable :means you can determine whether the objective was reached A-achievable : helps reduce unrealistic expectations. R-relevant : manages the issue of people trying to cram in every conceivable feature just in case. We want clear, concise T-time boxed :simply means we know when to call time if we havent achieved an outcome;

In TDD, code is never written without rst writing a test Clean interface because programmers write the test rst, the APIs they produce are naturally written from Adding New Functionality in TDD gives programmers the condence to change the larger architecture of an application

Disadvantages Of TDD?
programmers like to Code not to test

I N E N I G O G

its never seems to be built Testing/QA point of view Using TDD 100% quality not guaranteed We don't know that test/code was built against stakeholder view point or not.

Jai Chowdary Gogineni

Ref:The RSpec Book-David Chelimsky

What is BDD

oo

The Gherkin grammar


consists of a few keywords that you must use when you write a feature le:! Feature! Background! Scenario! Scenario outline! Scenarios (or examples)! Given! When! Then! And (or but)! | (which is used to dene tables)! """ (which is used to dene multiline strings) # (which is used for comments)!

Behaviour-Driven Development (BDD) builds upon Test-Driven Development (TDD) by formalising the good habits of the best TDD practitioners. The best TDD practitioners work from the outside-in, starting with a failing customer acceptance test that describes the behaviour of the system.With its roots in test-driven development, domain-driven design, and automated acceptance testing, BDD focuses on the ways an application is expected to work - its behaviour to get feedback from the business stakeholders about whether were setting out to build the right thing before we get started

I N E N I G O G

Advantages of BDD over TDD Automated Acceptance Testing


A project faces serious problems when its Business language is not understood throughout the their working domain. Domain experts use their specialised language, while technical team members have their own language tuned for discussing the domain in terms of design. The domain experts roughly describe what they want. Developers, struggling to understand a domain new to them, not fully understanding. if it isnt understood properly we end up building something not stakeholders wants this where BDD Came into frame as Cucumber is a tools is bridging to overcome these problems. Behaviour-Driven Development is about implementing an application by describing its behavior from the perspective of its stakeholders. Cucumber : Cucumber helps facilitate the discovery and use of a ubiquitous(common) language within the team, by giving the two sides of the linguistic(understandable) divide a place where they can meet. Cucumber tests interact directly with the developers code, but theyre written in a medium and language that business stakeholders can understand. By working together to write these testsspecifying collaborativelynot only do the team members decide what behaviour they need to implement next, but they learn how to describe that behaviour in a common language that everyone understands.When we write these tests before development starts, we can explore and avoid many misunderstandings long before they ooze their way into the codebase.

Feature :

With a title, a narrative, and the introductory line of a scenario

Scenario: Scenarios are concrete examples Steps :A step is generally a single line of text

I N E N I G O G
! !

of how we want the software to behave. Scenarios allow us to answer these questions by describing exactly what should happen under what circumstances. that starts with one of the step keywords: Given, When, Then, And, and But. Given indicates something that we accept to be true in a scenario When indicates the event in a scenario

Then indicates an expected outcome

Scenario Outline Cucumber lets us


Scenario Outline: Example! Given the secret code is "<code>"! When I guess "<guess>"! Then the mark should be "<mark>"!

dene a single scenario outline and then provide tables of input data and expected output. Heres the scenario outline for our submit

| code | guess | mark | ! |1234|1234 |++++| ! |1234|1243 |++ | ! |1234|1423 |+ |! |1234|4321 | |!

You might also like