why you should be doing bdd
Post on 15-Feb-2017
479 Views
Preview:
TRANSCRIPT
BDD is a process designed to aid the management and the delivery of software development projects by improving communication between engineers and
business professionals.
BEHAVIOR DRIVEN DEVELOPMENT
2
http://inviqa.com/insights/bdd-guide
4
✦ “There is no time”
✦ “It’s unnecessary extra code”
✦ “I know what I’m writing”
✦ “Client wants visible effect”
✦ and many more…
We are going to increase sale by
selling more products
GOAL
We are planning to achieve a 10% increase in sale in our web store
in 4 months
15
EXAMPLES
Given "PHP T-Shirt" is priced at €100.00
And the store has "VAT" tax rate of 23%
When I add product "PHP T-Shirt" to the cart
Then my cart taxes should be €23.00
16
20
✦ it adds two numbers
✦ it multiplies two numbers
✦ it subtracts two numbers
✦ it divides two numbers
✦ it not allows to divide by 0
WHAT DOES CALCULATOR DO?
21
HOW HARD CAN IT BE?
class CalculatorSpec extends ObjectBehavior { function it_adds_two_numbers() { $this->add(4, 5)->shouldReturn(9); }
function it_multiplies_two_numbers() { $this->multiply(3, 8)->shouldReturn(24); } function it_does_not_allow_to_divide_by_0() { $this ->shouldThrow(‘\InvalidArgumentException’) ->during(‘divide’, [10, 0]) ; } }
22
class ValidationMessageProviderSpec extends ObjectBehavior { function it_provides_happy_message_if_validation_passed( Validator $validator, ValidatedObject $object ) { $validator->validate($object)->willReturn(true); $this->provide($object)->shouldReturn(‘Great! Everything is fine!’); } }
HAVING FUN WITH MOCKS
STORY
24
It is an ancient need to be told stories. But the story needs a great storyteller.
~ Alan Rickman
FEATURE
26
In order to pay less while buying goods
As a Customer
I want to receive discount for my purchase
Receiving percentage discount promotion on order
SCENARIO
27
Given "PHP T-Shirt" is priced at €100.00
And the store has "VAT" tax rate of 23%
When I add product "PHP T-Shirt" to the cart
Then my cart taxes should be €23.00
BEHAT28
https://github.com/Behat/Behat
✦ uses Gherkin structured language
✦ used to describe application business logic
✦ really impressive
29
✦ Behat (PHP)
✦ PHPSpec (PHP)
✦ Cucumber (Ruby)
✦ JBehave (Java)
✦ Spock (Groovy)
✦ SpecFlow (.NET)
TOOLS
top related