23
© Schalk W. Cronjé Bangalore July 2013 Real World TDD Schalk W. Cronjé @ysb33r [email protected]

Real World TDD

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Real World TDDSchalk W. Cronjé

@[email protected]

Page 2: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Following a process / using TDD does not make your testing agile

Page 3: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

You can accept just to do what you are told

or you can decide to be better ...

Image: http://bit.ly/12FKyID

Page 4: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

TDD?

Test-driven Development ?

Test-driven Design ?

Page 5: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Myth #1

TDD is writing tests

before production code

Page 6: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

London School of Thought

TDD is growing code,

guided by tests

Page 7: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Myth #2

TDD is only about writing unit tests

Page 8: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

TDD is growing code ...

guided by

unit tests,

integration tests,

functional tests,

deployment tests

Page 9: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Myth #3

Test code does not have

to be well-written

Page 10: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

The test system is as important as the production code

http://dhemery.com/pdf/test-automation-zombie-apocalypse.pdf

Page 11: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Lean Startup Exception

In short-lived production code, don't bother with TDD

unless …

It helps you solve the problem

Page 12: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Myth #4

TDD is only for new code

Page 13: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

You can decide to be better ...

need a code change?

write a test first,

ensure it passes,

break it, fix it,

make the change

add code coverage

Page 14: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Gärtner's Cultural Patterns of Agile Testing

Separation

Pipelining

Mini-waterfalls

Integrated

Continuous

http://www.ministryoftesting.com/2013/07/cultural-patterns-in-agile-testing/

Page 15: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

deliveredbuild

Time Factors in Legacy Testing

Feature 3 Dev

Feature 2 Dev

Feature 4 Dev

Feature 1 Dev

BugDB

Feature 1 QA

Feature 2 QA

Feature 3 QA

Feature 4 QA

defect trickle feed

Feature 5+ Dev

Feature 5+ QA

deliveredbuild

Retest fixes QA

understandingspecs

time from raising defect until it is available for testing

Building testinfrastructure

time tore-test

basic buildverification

Page 16: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Test specification up front

Now everyone knows what we plan to test

Page 17: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Integrate Developers-Testers into pairs

Shared problem-solving leads to reduced cycle-time

“Two are better then, because they have good reward for their labor: If either falls down, one can help the other up. But pity anyone who falls and has no one to help them up”.

Ecclesiastes 4:9-10 NIV Translation~ 971 – 931 BC

Page 18: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Expressive Test Styledef "'and' should join groups when the thousands multiplier is not a multiple of one hundred" () {

expect:

EnglishNumbers.format( number ) == english_wording

where:

number | english_wording

120_000 | "one hundred and twenty thousand"

323_000 | "three hundred and twenty three thousand"

}

See also: BDD, ATDD, Specification by Example

Page 19: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Build a walking skeleton before any (more) features are written

Do the difficult whilst it is easy

– Sun Tzu, “Art of War”~ 512 BC

Image: http://bit.ly/15BTxMI

Page 20: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

One class One unit test One integration test One deployment script Continuous Integration Auto-deployment

Deployment-driven development

Page 21: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Advanced CI Orchestration

Expensive test sets should bedownstream and parallellised

http://delivervalue.blogspot.co.uk/2013/06/more-advanced-build-flows-with-jenkins.html

Page 22: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Conclusion● There is more than one way● Think big (beyond unit tests)● Be the one that makes the difference

Page 23: Real World TDD

© Schalk W. Cronjé Bangalore July 2013

Real World TDDSchalk W. Cronjé

@ysb33rysb33r @ gmail.com