Top Banner
David Funaro Let’s test! Andrea Giuliano #code10 #letstest
39
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: Let's test! @ codemotion 23/03/2013

David Funaro

Let’s test!

Andrea Giuliano

#code10 #letstest

Page 2: Let's test! @ codemotion 23/03/2013

Let’s test!

“Come ho fatto fino ad ora a lavorare senza test?”

“Non tornerei mai più indietro!”

Page 3: Let's test! @ codemotion 23/03/2013

Let’s test!

I manually test allmy code’s functionalities

write code features

Page 4: Let's test! @ codemotion 23/03/2013

Let’s test!

How (most) developerswrite code today

Page 5: Let's test! @ codemotion 23/03/2013

my starting project

Let’s test!

Page 6: Let's test! @ codemotion 23/03/2013

CHANGES

Let’s test!

internal external

Page 7: Let's test! @ codemotion 23/03/2013

be honest...

Let’s test!

Page 8: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

I’m looking forward to waste my code

Page 9: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

What happens when something goes wrong

Page 10: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

Where can I putmy hands in?

Page 11: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

one more patch

I’ve got the solution!

Page 12: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

I madesome mistakes

NO FEEDBACK

Page 13: Let's test! @ codemotion 23/03/2013

Let’s test!

? ????

??

I’m hopeless

Page 14: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

I want to be proudof my code

Page 15: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

Automatic Test

Page 16: Let's test! @ codemotion 23/03/2013

Let’s test!

Page 17: Let's test! @ codemotion 23/03/2013

Why automatic tests?

Let’s test!

confidence in your code

progressive input growth

no feartests as documentation easier to alter code

understand HOW code works

working software over comprehensive documentation

easy to rundon’t waste your time

feedback

Page 18: Let's test! @ codemotion 23/03/2013

How many kinds of test exists?Unit

FunctionalIntegration

more...

Let’s test!

Page 19: Let's test! @ codemotion 23/03/2013

we want short feedback!

Let’s test!

Page 20: Let's test! @ codemotion 23/03/2013

stress =1

# tests

Let’s test!

Page 21: Let's test! @ codemotion 23/03/2013

Ok, let’s try!I want to write a test for my code

Let’s test!

Page 22: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

Sounds good......but one day

Page 23: Let's test! @ codemotion 23/03/2013

Contents...

Let’s test!

How can I test this?coupling dependencies

Page 24: Let's test! @ codemotion 23/03/2013

Let’s test!

I don’t now so I DON’T test

Page 25: Let's test! @ codemotion 23/03/2013

Clean code that works cit. Ron Jeffries

predictable way to developlearn all of the lessons that the code has to teach you

improve the lives of the users of your softwarelet your teammates count on you, and you on them

feel good to write code

Let’s test!

Page 26: Let's test! @ codemotion 23/03/2013

How do we get to clean code that works?

Many forces drive us away from clean codeand even from clean code that works

Let’s test!

Page 27: Let's test! @ codemotion 23/03/2013

Test Driven Development

Let’s test!

Test-driven development is less and more writing test first...but TDD is about design

Test-driven development is a way of managing fear during programming

Page 28: Let's test! @ codemotion 23/03/2013

our tasks

Red: write a little test that doesn’t work

Green: make the test work quickly

Refactor: eliminate all the duplication created in merely getting the test to work

feature #1feature #2feature #3

Let’s test!

Page 29: Let's test! @ codemotion 23/03/2013

Let’s test!

write a test

Page 30: Let's test! @ codemotion 23/03/2013

Let’s test!

write a testit fails!

Page 31: Let's test! @ codemotion 23/03/2013

Let’s test!

write a test

make it works

it fails!

Page 32: Let's test! @ codemotion 23/03/2013

Let’s test!

write a test

make it works

it fails!awesomeit’s green!

Page 33: Let's test! @ codemotion 23/03/2013

Let’s test!

write a test

make it works

do refactor

it fails!awesomeit’s green!

Page 34: Let's test! @ codemotion 23/03/2013

Let’s test!

write a test

make it works

do refactor

it fails!awesomeit’s green!

Page 35: Let's test! @ codemotion 23/03/2013

what are the benefits?

improve quality of your codebehaviours’ verification

coverage functionalitytest as documentation

long term maintainabilityvery short time feedback about bugs

collaborative working

QA from reactive to proactive

Let’s test!

Page 36: Let's test! @ codemotion 23/03/2013

ok, it’s cool but my resources are limited

I want to be cheap

I want to be fast

I want to be good

Let’s test!

Page 37: Let's test! @ codemotion 23/03/2013

What about legacy code?

Test new functionalities

Test old functionalities starting from bugs

Let’s test!

Page 38: Let's test! @ codemotion 23/03/2013

DEMO

Let’s test!

Page 39: Let's test! @ codemotion 23/03/2013

Thanks!

Andrea Giuliano@bit_sharkandreagiuliano.it

David [email protected]

Questions?

Let’s test!