Top Banner
So long, and thanks for all the tests Seb Rose Claysnow Limited @sebrose Friday, 26 September 14
33

So long, and thanks for all the tests dev day krakow 2014

Dec 01, 2014

Download

Technology

Seb Rose

TDD has long been recommended by agile practitioners, but the community still argues about how to go about it. Inside-out or outside-in? Mockist or classical? Through a component's public API or for every class? And then there's Kent Beck's famous quote: “I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence.” This introduces a further level of subjectivity, especially since developers are frequently overconfident.

In this session, Seb will explore the choices that agile teams need to make when considering which development practices to adopt. He'll look again at some of the arguments for the different approaches and urge teams to practice until you're happy with the way you code.
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: So long, and thanks for all the tests   dev day krakow 2014

So  long,  and  thanks  for  all  the  tests

Seb  Rose

Claysnow  Limited

@sebrose

Friday, 26 September 14

Page 2: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 3: So long, and thanks for all the tests   dev day krakow 2014

Why do we test software?

“a process of gathering information about [software] with the intent that the information

could be used for some purpose”

Friday, 26 September 14

Page 4: So long, and thanks for all the tests   dev day krakow 2014

Developer tests

What are they for?• making sure the code works• preventing regressions• documenting the code• driving a testable design

Friday, 26 September 14

Page 5: So long, and thanks for all the tests   dev day krakow 2014

“I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a

given level of confidence ...

“I suspect this level of confidence is high compared to industry standards”

http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests/153565#153565

Friday, 26 September 14

Page 6: So long, and thanks for all the tests   dev day krakow 2014

Developer testing

When do you write tests?• never• after writing the code• while you write the code• before writing the code

Friday, 26 September 14

Page 7: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 8: So long, and thanks for all the tests   dev day krakow 2014

http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations

Any objections?

Friday, 26 September 14

Page 9: So long, and thanks for all the tests   dev day krakow 2014

http://claysnow.co.uk/to-tdd-or-not-to-tdd/

To TDD or not to TDD?

That i

s NOT

the qu

estion

!

Friday, 26 September 14

Page 10: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 11: So long, and thanks for all the tests   dev day krakow 2014

Dreyfus model of skill acquisition

http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition

Friday, 26 September 14

Page 12: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 13: So long, and thanks for all the tests   dev day krakow 2014

Listen to your tests

Friday, 26 September 14

Page 14: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 15: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 16: So long, and thanks for all the tests   dev day krakow 2014

What is a unit test anyway?

A test is not a unit test if:• It talks to the database• It communicates across the network• It touches the file system• It can’t run at the same time as other

unit tests• You have to do special things to your

environment (such as editing config files) to run it

http://www.artima.com/weblogs/viewpost.jsp?thread=126923

Friday, 26 September 14

Page 17: So long, and thanks for all the tests   dev day krakow 2014

http://codebetter.com/iancooper/2011/10/06/avoid-testing-implementation-details-test-behaviours/

Test behaviours not implementation details

“When we refactor we don’t want to break tests. If our tests know too much about our

implementation, that will be difficult, because changes to our implementation will necessarily

result in us re-writing tests – at which point we are not refactoring. We would say that we have over-

specified through our tests.

Instead of assisting change, our tests have now begun to hamper it.”

http://vimeo.com/68375232

Friday, 26 September 14

Page 18: So long, and thanks for all the tests   dev day krakow 2014

Properties of unit testing

UnderstandableMaintainableRepeatableNecessaryGranular

Fast

Friday, 26 September 14

Page 19: So long, and thanks for all the tests   dev day krakow 2014

Q. How can we test components in isolation?

A. Seams

Friday, 26 September 14

Page 20: So long, and thanks for all the tests   dev day krakow 2014

The Meszaros taxonomy

http://xunitpatterns.com

■Dummy objects are passed around but never actually used.■Fake objects have working implementations.■Stubs provide canned responses'.■Mocks are pre-programmed with expectations which form a specification of the calls they are expected to receive.

Friday, 26 September 14

Page 21: So long, and thanks for all the tests   dev day krakow 2014

Mocking in a nutshell

Friday, 26 September 14

Page 22: So long, and thanks for all the tests   dev day krakow 2014

Mocking can make a terrible mess

Friday, 26 September 14

Page 23: So long, and thanks for all the tests   dev day krakow 2014

Mocking can give you a false sense of securityvia JB Rainsberger, GOOS mailing list, “Unit-test mock/stub assumptions rots”, 15 March 2012

Friday, 26 September 14

Page 24: So long, and thanks for all the tests   dev day krakow 2014

How valuable are your tests?

Friday, 26 September 14

Page 25: So long, and thanks for all the tests   dev day krakow 2014

http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.html

Friday, 26 September 14

Page 26: So long, and thanks for all the tests   dev day krakow 2014

http://www.slideshare.net/dannorth/accelerating-agile-testing

Friday, 26 September 14

Page 27: So long, and thanks for all the tests   dev day krakow 2014

http://www.slideshare.net/dannorth/accelerating-agile-testing

Friday, 26 September 14

Page 28: So long, and thanks for all the tests   dev day krakow 2014

http://pitest.org

Mutation testing

Friday, 26 September 14

Page 29: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 30: So long, and thanks for all the tests   dev day krakow 2014

Friday, 26 September 14

Page 31: So long, and thanks for all the tests   dev day krakow 2014

Developer tests - recap

What are they for?• making sure the code works• preventing regressions• documenting the code• driving a testable design

Friday, 26 September 14

Page 32: So long, and thanks for all the tests   dev day krakow 2014

Things that seem important to me:

- chase the VALUE- identify the RISKS- understand your CONTEXT

The tests should make your life EASIER

Friday, 26 September 14

Page 33: So long, and thanks for all the tests   dev day krakow 2014

Seb  Rose

Twi;er:     @sebrose

Blog:       www.claysnow.co.uk

E-­‐mail:     [email protected]

Seb Rose,

Availa

ble No

w

in bet

a

Friday, 26 September 14