the key to move really fast – lightning talk | niclas nilsson | ltg-43/dtg-7

57
The key to move really fast

Upload: lean-tribe

Post on 22-Jan-2018

269 views

Category:

Software


1 download

TRANSCRIPT

The key to move really fast

Niclas Nilsson

Jon-Erling Dahl

Coaching and consulting

Automates your paperwork

The new reality

Release more often

Solution:

Test automation

Automation of System Tests

"We have unit tests with good coverage."

Acceptance Tests > Unit Tests

2 unit tests

0 acceptance tests

We need automated acceptance tests

BDDBehaviour Driven Development

ATDDAcceptance-Test Driven

Development

Communicate throughstories

ATM exampleFeature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM

Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20

Not just happy casesScenario: Account has insufficient funds Given the account balance is 10 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should be 10 And the card should be returned Scenario: Card has been disabled Given the card is disabled When the account holder requests 20 Then the ATM should retain the card

StoriesAll in plain textWorks well on paperIf only we could execute it...

Cucumber

http://cukes.info

“Cucumber is a tool for runningautomated tests written in plain

language”

Features in plain textFeature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM

Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20

Not just happy casesScenario: Account has insufficient funds Given the account balance is 10 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should be 10 And the card should be returned Scenario: Card has been disabled Given the card is disabled When the account holder requests 20 Then the ATM should retain the card

Features in plain textFeature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM

Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20

Stepsin any programming language

CucumberSpecflowBehat...and many more

Unit testsCovers smaller units/componentsFast execution timesVery technicalGood for complex algorithmsGood for reusable components

Acceptance testsCovers slices of the complete systemSlower execution timesIntentionalGood for the complete systemGood for avoiding complex/subtle integration bugsProvides a holistic safety net

Test through the browser

Hit the database

Only mock external systems

"But that's so slow..."

True.But the value is much higher.

"But it's quite hard..."

At first.But it gets quite easy after the initial

efforts.

"But it takes more time..."

True. At first.But after a short while, you get

much faster.

And by the way:

You can actually have thecookie and eat it too.

How to have the cookie and eat it too:The feature specs should always hold.But you can have multiple sets of step definitions- Full scale, including UI and DB- Lighter and faster, no UI, no DBNote: The same feature specs - different step impls!

Unit tests cannot replace acceptance tests

but...

Acceptance tests can replace unit tests

Most good systems have both

Avoid record/replayOften very brittle

Craft them well.

And remember...

Acceptance Tests > Unit Tests

Niclas Nilsson

[email protected]

@niclasnilsson

We help you get started