3. • Started as developer in 2006 at Litera
• In 2009 moved to USA
• In 2011 started at Levi9 Ukraine
• Currently
• Head of .Net department
• .Net Architect
• Lead of Agile competence area in Kiev delivery center
• Scrum Master at Exact, running 2 teams
HOW I AM ?
4. WHAT WE ARE DOING AT EXACT
• Code design
• SOLID
• Clean Code
• XP practices
• UI testing
• Unit Testing
• Integration Testing
• Pair programming
• TDD
5. RESULT
• Developer really thinking about code design
• Better code (design, coupling, patters,
cleaner…)
• Test coverage increased
• More trust in code
• Better cooperation between SE
• Developer more happier
7. WHY?
• User story acceptance criteria are well defined
• We did not change requirements during the sprint
• We already have some mockups, flow diagrams
• Team became more experience
• Team produces even more code than before
• Etc
• Looks like nothing has changed …
13. • It’s more than just testing, it’s a process.
• Automated tests specifications in human-readable language
• More collaboration between domain experts, product owners,
QA and developers.
Most useful for achieving automated acceptance testing:
Together with a domain expert you define the acceptance criteria in
a specification.
This specification can be executed against the system under test.
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
14. • Example
• Expectation
• Should
• Behavior
• Specification
• Given When Then
• Test →
• Assertion →
• assert →
• Unit →
• Verification →
• Arrange Act Assert
• … and so on
BDD IS MORE THAN “TDD DONE RIGHT”
15. Story: Returns go to stock
As a store owner
I want to add items back to stock when they're returned
In order to keep track of stock
Scenario 1: Refunded items should be returned to stock
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario 2: …
User story
(just scrum)
All scenarios that should
be handled for this user
story to be “Done”
STORY TO BDD SCENARIO
16. System under testSpecification
Story: Returns go to stock
As a store owner
I want to add items back to stock when they're returned
In order to keep track of stock
Scenario 1: Refunded items should be returned to stock
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario 2: …
Then: validate the system
state
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
17. • xBehave – for everyone (SpecFlow, NBehave)
• xSpec – for developers (MSpec, NSpec, )
2 TYPES OF BDD
19. FEATURE FILE
Scenario: login a as user
Given I am logged in as CustomerTrade:
When I execute GET /api/Accounts/{id}
Then the status code should be 200
And the result should contain the following:
| Name | AddressLine1 |
| ConnectivityTest | Main street 12 |
20. [Given(@"I am logged in as (.+)")]
public void GivenIAmLoggedIn(string name)
{
// do something in the system under test
// application.login(name);
}
We create a test language of regular expressions.
We bind recognized sentences to C#/VB.NET commands.
That’s why we call these definitions bindings.
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
21. Specification
Story: Returns go to stock
As a store owner
I want to add items back to stock when they're returned
In order to keep track of stock
Scenario 1: Refunded items should be returned to stock
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario 2: …
C# / VB.NET
Test case for
each scenario
Bindings
definition of a Test
Language
MSTest/nUnit/xinut
Test Runner
PASS/FAIL
per scenario
parse all
steps
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
22. Where does BDD fit in?
BDD can actually be applied at many
levels, but is most effective for
automated acceptance tests.
Unit tests are about software
verification
Are we building the software right?
Acceptance tests are about software
validation
Are we building the right software?
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
23. BENEFITS
• Speed up feature delivering by decreasing defects
• Helped facilitate a conversations with the business
through a common language
• Developers and non-developers both writing tests
and taking ownership.
• Better understanding what is covered by SE and QE