Top Banner
Benefits of Test Driven Development Venkat Subramaniam [email protected] @venkat_s
32

Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Sep 25, 2018

Download

Documents

donhi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Benefits of Test Driven Development

Venkat [email protected]

@venkat_s

Page 2: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Why do it?

Programming already is time consuming, why would you take on additional task of writing tests?

2

Page 3: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Why do it?

This one is counterintuitive—to save time!

3

Page 4: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

How?

Let’s answer that question...

4

Page 5: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

What’s Agility?

It’s our ability, as individuals, teams, and organizations to respond to ever changing business conditions

5

Page 6: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

What’s Agile Development?

It is Feedback Driven Development

6

Page 7: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Feedback is Critical

The requirements you start with may not be the ones you end up within the release

If your objective is to build what your customers wanted, you will fail—you need to build what they still want, what’s relevant

7

Page 8: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Feedback Driven

8

CustomerExpectations/

Relevance

ProgrammerExpectations

Which is more important?

Page 9: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Feedback Driven

9

Both types of feedback are equally important

You want rapid feedbackYou want to avoid Whack-a-mole software

Page 10: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Sustainability is the key

Agile development is not about running fast...

It is about running fast in the right direction at a sustainable pace

10

Page 11: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

TDD helps?

TDD is a way to get rapid feedback

As you evolve the system based on feedback, bug fixes, and additional features, it tells you...

...that the code worked and continues to work as expected

11

Page 12: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

But it costs to do TDD

Dr. Laurie William’s research study...

... experienced programmers

... two teams

... one doing TDD, the other simply coding

...result?

12

Page 13: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

But it costs to do TDD

In the beginning, first version

team that did TDD took 16% more time

When asked to make change, team that did TDD came back first and things simply worked

Team that did not do TDD not only came back much later, but their code no longer worked... they had created whack-a-mole software!

13

Page 14: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Cost of not doing it?

We know this as a pain in the industry

delayed software release

hard to maintain

hard to predict

hard to change

frustration for everyone, programmers, testers, managers, marketing, sales, support, ...the entire organization

14

Page 15: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Yet, industry-wide...

“Insanity: Doing the same thing over and over again and expecting different result”—Einstein

15

Page 16: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Software and Complexity

One of the most troubling words in software development is "entropy," knowingly or not, we spend lots of effort dealing with that.

16

Page 17: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Software Rot

Software gets complex rather quickly and becomes unmanageable

Several forces are against us

the domain

the infrastructure

the tools

and the change17

Page 18: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

How to cope?

Two kinds of design: Strategic and Tactical

Strategic design is important, but we have to do it to the right level

Keep it minimal and evolve

TDD helps with tactical design, to keep the complexity at manageable level, continuously

18

Page 19: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Automation is critical

Without the proper amount of automation, it is impossible to sustain software development - agile or not

19

Page 20: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

What Pushes us to Waterfall?

20

Requirements Analysis Design Coding Integration

Testing & Bug Fixing

Too late in the game

Often pressure to release

QA become defenders

Often looked at as adversaries

Page 21: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

In Agile Development...

21

Testing starts early & is Continuous

Don’t wait until end of iteration to test–test frequently and regularly

Application is exercised constantly, no surprises later

QA become support

Not adversaries, become part of the team

Work with customer and programmers—co-located with them

Testing & Code FixAnalysis/Design & Coding

Delta of Requirements

Page 22: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Tenets of Testing

As a tester, your responsibility is to author tests, not run them!

22

Page 23: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Automation is Essential

“Error rate in manual testing is comparable to the bug rate in code being tested.”—Boriz Beizer

You can’t sustain the pace with manual testing

Starting very early with automation makes life easy

23

Page 24: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Types of TestsWhite-box testing—Programmers

Test greatly influences and is influenced by the internal

design of the code. Is fine grained.

Black-box testing—Testers and customers with collaboration with Programmers

Test focuses on the external behavior of the code

without regard to its internal structure. Is coarse

grained. 24

Page 25: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Where not to Automate?

25

Not Effective

Very hard to automate

Too BrittleBrittleBrittle

BusinessLogic

Test Test Test Test

GUI

Page 26: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Where to Automate?

26

GUI

BusinessLogic

Run Automated Testsone level below GUI

Page 27: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

What’s Needed for TDD?

One word: Discipline

Everything else follows it

27

Page 28: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Programming without automated testing is a

roadkill

28

Page 29: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

29

Unit testing is the software equivalent

of exercising

Page 30: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

“Some people change when they see the light, others

when they feel the heat”—Caroline Schoeder.

30

Page 31: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Remember the wise words of uncle Ben

31

“With great power comes great responsibility”—in

Spiderman

Page 32: Benefits of Test Driven Development - … · But it costs to do TDD In the beginning, first version team that did TDD took 16% more time When asked to make change, team that did

Venkat [email protected]

twitter: @venkat_s

Thank You!