Upload
itspringby
View
121
Download
0
Tags:
Embed Size (px)
Citation preview
• 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 ?
WHAT WE ARE DOING AT EXACT
• Code design • SOLID• Clean Code
• XP practices• UI testing• Unit Testing• Integration Testing • Pair programming • TDD
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
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 …
• 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?
• 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”
Story: Returns go to stockAs a store ownerI want to add items back to stock when they're returnedIn order to keep track of stock
Scenario 1: Refunded items should be returned to stockGiven a customer previously bought a black sweater from me And I currently have three black sweaters left in stockWhen he returns the sweater for a refundThen 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
System under testSpecificationStory: Returns go to stockAs a store ownerI want to add items back to stock when they're returnedIn order to keep track of stock
Scenario 1: Refunded items should be returned to stockGiven a customer previously bought a black sweater from me And I currently have three black sweaters left in stockWhen he returns the sweater for a refundThen I should have four black sweaters in stock
Scenario 2: …
Given: prepare test data in the
system
When: trigger a function in
the system
Then: validate the system state
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
• xBehave – for everyone (SpecFlow, NBehave)
• xSpec – for developers (MSpec, NSpec, )
2 TYPES OF BDD
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 |
[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?
SpecificationStory: Returns go to stockAs a store ownerI want to add items back to stock when they're returnedIn order to keep track of stock
Scenario 1: Refunded items should be returned to stockGiven a customer previously bought a black sweater from me And I currently have three black sweaters left in stockWhen he returns the sweater for a refundThen I should have four black sweaters in stock
Scenario 2: …
C# / VB.NETTest case for each scenario
Bindings definition of a Test Language
MSTest/nUnit/xinutTest Runner
PASS/FAIL per scenario
parse all steps
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
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 verificationAre we building the software right?
Acceptance tests are about software validationAre we building the right software?
WHAT IS BEHAVIOUR-DRIVEN DEVELOPMENT?
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