Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Beyond TDD

Introduction to the behaviour driven development (BDD)

Ider Delzo

on 23 December 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Beyond TDD

Beyond TDD...
Ider Delzo
@Taller Technologies
The Problem...
with a plus...
Well done
TestPrettyMethod... doesn't mean much .
Sometimes you need a state verification
You are very obsessed about test ... ¿What happens if I delete one?...
The Design...
Sometimes we don't focus at the moment of choice a better name for our test:
class TestPerson:
def test_set_name(self):
def test_set_age(self):
class TestPerson:
def test_set_name_should_save_the_name(self):
def test_set_age_should_save_if_age_is_valid(self):
def test_set_age_should_thows_exeption_if_age_is...
Names mean a lot, if the test fails you know what is broken and the most important
this influences in you design
State vs Behavior
I dont say... I do...
class EmailMock(EmailClass):
def __init__(self):
email_sent = 0

def send_email(self):
email_sent += 1

class TestReportClass():
def test_save_and_send_sould_send_email(self):
reporter = Reporter()
mailer_mock = EmailMock()
reporter.mailer = mailer.mock
#do stuff
assert mailer_mock.email_sent == 1
from mockito import *

class TestReportClass():
def test_save_and_send_sould_send_email(self):
reporter = Reporter()
mailer_mock = mock()
reporter.mailer = mailer.mock
#do stuff
It can be changed the internal state of the collaborators but no the interaction with the SUT
DeleteTestPhobia: Afraid of Test Deletion
If the behavior of a funcionality change the tests changes too, if the functionality disapear, the test should be erased.
Looking for Solutions
Design the test based in the behaviors.
Keep the names simpler but very expressive as you can.
Your tests should cover just the behavior and the interactions but no state.
But there's another way to do it simpler...
The First Evolution
BDD was developed by Dan North as an evolution from TDD, it uses a more readable language and introduce some good practices from TDD developers.
As Dan North says:
"BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters."
Ok It's interesting...
Show me The code!
Example 1: RSpec like tools
Have you realized...?
It's a human friendly language
The stakeholders are humans too
The requirements from stakeholders can be expressed by examples
The requirements are behaviors too
Evolving into an Ubiquitous Language
There's a big approach that Dan North suggest: it's about using a ubiquitous language for the definition of acceptance tests, it uses a natural language and it's easy to understand for no tech people.
Let's inside...
In order to
don’t have to wait in line at the bank
As a
I want to
withdraw cash from an ATM.
Scenario 1
: Account is in credit
the account is in credit
the card is valid
the dispenser contains cash
the customer requests cash
ensure the account is debited
ensure cash is dispensed
ensure the card is returned
Principal Advantages:
Easy to read easy to write... for everyone
It gives you a starting point to start a feature
The language is not using an Id or UI term so you can change the interface but no the specs.
The specification can be automated and you can install it on your preferred CI Server.
Let's Rock
Example 2 Cucumber like tools
So... Whats next?
Integrate with the CI
Improve and expand the process using Specification by example
Full transcript