Руслан Плахута - Внедрение bdd в распределенные команды

24
How it can help your team be more productive? BDD

Upload: itspringby

Post on 15-Aug-2015

114 views

Category:

Leadership & Management


0 download

TRANSCRIPT

How it can help your team be more productive?

BDD

CONTENT

• Introduction• How we came to BDD?• What is BDD in general?• BDD with SpecFlow• Benefits

• 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

PROBLEM

Time of releasing a feature has increased!

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 …

DEVELOPMENT FLOW

Dev

Test

PO check

Production

Dev

TestPO check

SCRUM REFINEMENT

ILLUSTRATED WITH SHARED EXAMPLE

DISCOVERING NEW ASPECTS

SOUNDS LIKE BDD, DOESN`T IT?

• 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

SPECFLOW

PM> Install-Package SpecFlow.NUnit

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

QUESTIONS