TDD ist fr Trumer, nicht fr Praktiker, oder? Sven Amann - - PowerPoint PPT Presentation

tdd ist f r tr umer nicht f r praktiker oder
SMART_READER_LITE
LIVE PREVIEW

TDD ist fr Trumer, nicht fr Praktiker, oder? Sven Amann - - PowerPoint PPT Presentation

TDD ist fr Trumer, nicht fr Praktiker, oder? Sven Amann academicscode.com letsdeveloper.com @svamann artwork by Sven Amann - CC BY-SA 4.0 Why TDD (discussions)? Why do I talk about TDD? Sven Amann artwork by Sven Amann - CC BY-SA


slide-1
SLIDE 1

TDD ist für Träumer,
 nicht für Praktiker,

  • der?

Sven Amann academicscode.com letsdeveloper.com @svamann

artwork by Sven Amann - CC BY-SA 4.0

slide-2
SLIDE 2

Why do I talk about TDD? Why TDD (discussions)?

artwork by Sven Amann - CC BY-SA 4.0

Sven Amann

slide-3
SLIDE 3

artwork by Sven Amann - CC BY-SA 4.0

Academics code

Physicist Computer Scientist

slide-4
SLIDE 4

artwork by Sven Amann - CC BY-SA 4.0

A Pro

slide-5
SLIDE 5

Introduction to Computer Science I - WS06/07

artwork by Sven Amann - CC BY-SA 4.0

slide-6
SLIDE 6

“Faster development, higher code quality, better design, and less waste!” Kent Beck “Self-testing code and clean interfaces!” Martin Fowler “Exhaustive test suites, close to no debugging, changing code without fear, reduced coupling, …” Uncle Bob “Fast feedback and safe refactoring” James Shore

slide-7
SLIDE 7

Academics code

artwork by Sven Amann - CC BY-SA 4.0

slide-8
SLIDE 8

Academic Industry Developer

artwork by Sven Amann - CC BY-SA 4.0

slide-9
SLIDE 9

Academic Industry Developer

artwork by Sven Amann - CC BY-SA 4.0

slide-10
SLIDE 10

Academic Industry Developer

artwork by Sven Amann - CC BY-SA 4.0

slide-11
SLIDE 11

“TDD is dead. Long live testing” DHH “TDD needs a funeral.” Cope “The real "problems" with TDD [is] in the "driven" part, not the "test" part [and] the zealotry of some of its evangelists” Rich Hickey

slide-12
SLIDE 12

?!?

artwork by Sven Amann - CC BY-SA 4.0

slide-13
SLIDE 13
slide-14
SLIDE 14

Agile Alliance TDD

1976: The Dark Age of Developer Testing
 “a developer should never test their own code”


Glenford Myers in “Software Reliability”

1994 - Kent Beck develops SUnit 1999 - Kent says “test first” in “XP Explained” until 2002 - “test first” evolves to “test driven”

Source: https://www.agilealliance.org/glossary/tdd/

slide-15
SLIDE 15

Queueing Theory

Source: http://blog.jbrains.ca/permalink/how-test-driven-development-works-and-more

slide-16
SLIDE 16

Test-first Programming

Source: http://blog.jbrains.ca/permalink/how-test-driven-development-works-and-more

slide-17
SLIDE 17

Uncle Bob’s Three Laws of TDD

  • 1. You are not allowed to write any

production code unless it is to make a failing unit test pass.

  • 2. You are not allowed to write any more
  • f a unit test than is sufficient to fail;

and compilation failures are failures.

  • 3. You are not allowed to write any more

production code than is sufficient to pass the one failing unit test.

Source: http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd

slide-18
SLIDE 18

Classic

TDD

slide-19
SLIDE 19

Classic

TDD

Test: 1 = “I” return “I”; Test: 2 = “II” return (i == 1) ? “I” : “II”; Test: 3 = “III” return i * “I”; ...

slide-20
SLIDE 20

Classic

TDD

  • Roman Numbers
  • FizzBuzz
  • Bowling Game
  • Game of Life
  • Harry Potter Book Sets

Algorithms with well-defined input-output relation

slide-21
SLIDE 21

Test! !Test

artwork by Sven Amann - CC BY-SA 4.0

slide-22
SLIDE 22

–John Sonmez

“By writing unit tests ... you find all kinds of problems with that code ... of those units [but] unit testing is more of an appraisal activity than a testing one... very few regressions are caught by unit tests since changing the unit of code you’re testing almost always involves changing the unit test itself.”

slide-23
SLIDE 23

Table 3-25, p. 179

slide-24
SLIDE 24

Developer Test ≠ Acceptance Test

artwork by Sven Amann - CC BY-SA 4.0

slide-25
SLIDE 25

“a developer should never test their own code”

–Glenford Myers artwork by Sven Amann - CC BY-SA 4.0

self control

slide-26
SLIDE 26

Developer tests are our job!

artwork by Sven Amann - CC BY-SA 4.0

slide-27
SLIDE 27

Test

Test B

Test Waste Valuable Tests

artwork by Sven Amann - CC BY-SA 4.0

TDD Tests

slide-28
SLIDE 28

Required Functionality All It Can Do

artwork by Sven Amann - CC BY-SA 4.0

Waste

slide-29
SLIDE 29

Toy Project Real Software ???

slide-30
SLIDE 30

Test-driven Programming

Source: http://blog.jbrains.ca/permalink/how-test-driven-development-works-and-more

slide-31
SLIDE 31

London School TDD

slide-32
SLIDE 32

London School TDD

Source: http://coding-is-like-cooking.info/tag/london-school-tdd/

slide-33
SLIDE 33

???

Sale Catalog Display Acceptance Test: “Sell One Item”

slide-34
SLIDE 34

–James O. Coplien (Cope)

“TDD was created to replace up-front

  • architecture. It is not a testing technique.”

Source: https://twitter.com/jcoplien/status/828291686128304130

slide-35
SLIDE 35

class Person def age Date.today.year - birthday.year end end test “a person’s age is determined by birthday” do seventy_niner = Person.new birthday: Date.new(1979) travel_to Date.new(2009) assert_equal 30, seventy_niner.age end

slide-36
SLIDE 36

artwork by Sven Amann - CC BY-SA 4.0

class Person def age(now = Date.today) now - birthday.year end end test “a person’s age is determined by birthday” do seventy_niner = Person.new birthday: Date.new(1979) assert_equal 30, seventy_niner.age Date.new(2009) end

slide-37
SLIDE 37

First Design, then Code, then Test. That’s how we’ve always done it.

artwork by Sven Amann - CC BY-SA 4.0

Traditional Waterfall Testing Agile Over-Enthusiast

All but that…

slide-38
SLIDE 38

–David Heinemeier Hansson (DHH)

“Writing software is more like writing french poetry than a hard science.”

slide-39
SLIDE 39

The Ultimate Design (You’ll Never Need)

artwork by Sven Amann - CC BY-SA 4.0

slide-40
SLIDE 40

–Joe Rainsberger (jbrains)

“TDD doesn't create design. You do.”

slide-41
SLIDE 41

Check Your Own Work Cleanup After Your TDD Remember To Think Listen Closely & Consider the Context

slide-42
SLIDE 42

–Joe Rainsberger (jbrains)

“TDD Is Not Magic. The rules themselves do not guarantee success. You have to keep the brain switched on. You have to pay attention to what’s

  • happening. You need a place to ask questions

and get answers. You need to know that when you practise TDD, your code starts to speak to you, but in a language you [may not yet] understand, and that when you write tests and run them, this act equates to learning a language by hearing it, trying to speak it, and by native speakers correcting you. If you do these things, then I expect TDD to “work” for you.”

slide-43
SLIDE 43

Sven Amann academicscode.com letsdeveloper.com youtube.com/letsdeveloper @svamann

artwork by Sven Amann - CC BY-SA 4.0