atdd in practice

27
ATDD in practice Andrei Marukovich [email protected] Twitt er: @amarukovich Blog: lunarfrog.com/blog

Upload: andrei-marukovich

Post on 02-Nov-2014

2.169 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: ATDD in practice

ATDD in practice

Andrei [email protected]

Twitter:

@amarukovich

Blog: lunarfrog.com/blog

Page 2: ATDD in practice

2

Agenda

• What is Acceptance Test Driven Development?

• ATDD in depth

• SpecFlow demo

Page 3: ATDD in practice

3

Story of ProjectX

• Ingredients of success• Dedicated team and comfortable

schedule• Continues integration server• High Unit Tests coverage• Regular architecture reviews• Metrics analyzes

Page 4: ATDD in practice

4

Project was rejected by the customer

“Actually, we asked for something different”

Page 5: ATDD in practice

5

Reason of the failure

Sales Department

Development Team

Customer

1. Initial requirements

Lack of communication

2. Adjusted requirements

3. Wrong product

Page 6: ATDD in practice

6

ATDD is about…

• Communication

• Collaboration

• Process improvements

• Better specifications

Page 7: ATDD in practice

7

ATDD is not about frameworks

Page 8: ATDD in practice

8

Definition

• TDD helps to develop product right

• ATDD helps to develop right product

• Other names:• Behavior Driven Development• Specification by example• Executable specification

Page 9: ATDD in practice

9

ATDD and TDD

Develop

Deliver

Specify

Red

Green

Refactor

TDD

ATDD

Page 10: ATDD in practice

10

Specify

All stakeholders collaborate on specification

Domain Developers Testers

Define Clarify Verify

Specification

Specification based on common understanding

Page 11: ATDD in practice

11

Workshop types

• Full team

• Mini-team• 1 domain expert + 1 developer + 1

tester

• Pairing• Useful for extending existing

specifications

Page 12: ATDD in practice

12

Specification

• Use domain language

• Testable

• Includes scenarios and examples

Page 13: ATDD in practice

13

Specification example

Feature: New user registration In order to be able to use site As a new user I want to be able to register an account

Scenario: Successful registration Given I am on Registration page When I entered unique name And I entered valid password Then a new account is created

Page 14: ATDD in practice

14

Executable specification benefits

• Better definition of scope and “done”

• More scenarios identified upfront

• Preventing defects is cheaper than fixing them

• Prevents system regression

Page 15: ATDD in practice

15

What to specify

• User Interface?

• Business logic?

• Data access layer?

• Algorithms?

Everything, if it make sense for customer

Page 16: ATDD in practice

16

Consider maintenance cost

UI and AlgorithmsBusiness logic and DAL

Page 17: ATDD in practice

17

How to specify

• Define system behavior, not steps• Simplifies long term maintenance• Captures domain knowledge

• Do not rely on implementation details

• Test should be self-describing• Define allowed and disallowed scenarios• Provide right and failing examples

• Use iterative approach• Start with defining of the happy path

• Use domain language

Page 18: ATDD in practice

18

What’s next?

It’s time to automate your specifications

Page 19: ATDD in practice

19

Frameworks - FIT

Page 20: ATDD in practice

20

Fixture implementation

FIT Fixture Production Code

Page 21: ATDD in practice

21

FIT Action fixture

Page 22: ATDD in practice

22

Given-When-Then frameworks• Cucumber

• Cuke4Nuke

• SpecFlow

Page 23: ATDD in practice

23

Gherkin style specification

Feature: New user registration In order to be able to use site As a new user I want to be able to register an account

Scenario: Successful registration Given I am on Registration page When I entered unique name And I entered valid password Then a new account is created

Page 24: ATDD in practice

24

Demo

SpecFlow demo

Page 25: ATDD in practice

25

Test maintenance

• Automation code is code – follow all good habits

• Document building blocks

• Split the test – fast, slow, stable

• ATDD can be used for integration but keep integration and functional tests separately

Page 26: ATDD in practice

26

Way for a better specifications• Collaborative approach

• Specify behavior, not implementation

• Testable requirements

• Automate specification tests

• Control specification maintainability

Page 27: ATDD in practice

Thank you!

27

lunarfrog.com/blog

@amarukovich