SlideShare une entreprise Scribd logo
1  sur  68
Télécharger pour lire hors ligne
So	
  long,	
  and	
  thanks	
  for	
  all	
  the	
  
tests
Seb	
  Rose
Claysnow	
  Limited
@sebrose
Friday, 2 May 14
Friday, 2 May 14
“The last ever dolphin message was
misinterpreted as a surprisingly sophisticated
attempt to do a double-backwards-somersault
through a hoop whilst whistling the 'Star
Spangled Banner', but in fact the message was
this: So long and thanks for all the fish.”
http://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_(novel)
Friday, 2 May 14
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, 2 May 14
Developer tests
What are they for?
• making sure the code works
• preventing regressions
• documenting the code
• driving a testable design
Friday, 2 May 14
“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, 2 May 14
Friday, 2 May 14
Developer testing
When do you write tests?
• never
• after writing the code
• while you write the code
• before writing the code
Friday, 2 May 14
http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations
Any objections?
Friday, 2 May 14
“Takes too much time to write tests.”
“If I change something it will break a whole
bunch of tests that I will have to fix and it will
be more work for me in the end than just
verifying my changes manually.”
“Running the tests takes too long.”
http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations
Friday, 2 May 14
“No scientific proof of it actually having any
benefit (compared to just code reviews, pair
programming or etc.) for the same amount of
time”
“It's not practical for the kind of work I do. By
which I mean, it cannot be conclusively shown
to provide tangible benefits that outweigh the
perceived costs.”
http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations
Friday, 2 May 14
TDD - Where did it all go wrong?
Ian Cooper - http://vimeo.com/68375232
Why are people abandoning TDD?
- Test first is unproductive obstacle
- Faster feedback gives the competitive advantage
- It’s difficult to understand the test’s intent
Friday, 2 May 14
Accelerating agile
Dan North - http://vimeo.com/68215534
Isn’t agility about speed?
- Fast feedback
- Understand the risk
- Use appropriate methods
http://programmingandthecity.wordpress.com/2013/09/30/whats-dan-north-wearing-today/
Friday, 2 May 14
TDD is dead
David Heinemeier Hansson-
http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html
http://david.heinemeierhansson.com/2014/test-induced-design-damage.html
TDD isn’t useful anymore
- We’ve learnt what we needed
- Unit tests aren’t useful
- Testability hurts the design
Friday, 2 May 14
Oh no it’s not
Robert C. Martin (aka Uncle Bob) -
TDD is still useful
- Unit tests are fast and thorough
- It’s not universally applicable
- Decomposition is good design
http://blog.8thlight.com/uncle-bob/2014/04/25/MonogamousTDD.html
http://blog.8thlight.com/uncle-bob/2014/04/30/When-tdd-does-not-work.html
http://blog.8thlight.com/uncle-bob/2014/05/01/Design-Damage.html
Friday, 2 May 14
Queuing theory
JB Rainsberger -
http://www.jbrains.ca/permalink/how-test-driven-development-works-and-more
Given a process B, which follows a process A,
sometimes in performing B we need to perform
some of A again. We can remove the need to
rework by taking some portion of process B and
performing it before process A
Friday, 2 May 14
“With emergent design, a development organization
starts delivering functionality and lets the design
emerge.
...while it is being built, the organization will [...]
refactor out the commonality ...
At the end [we are] left with the smallest set of the
design needed, as opposed to the design that could
have been anticipated in advance.”
Emergent design
http://en.wikipedia.org/wiki/Emergent_Design
Friday, 2 May 14
http://effectivesoftwaredesign.com/2013/10/18/avoiding-technical-debt-how-to-accumulate-technical-
savings/
Adaptable design up-front?
“... software systems must evolve, and
that this evolution must be supported
through well planned, adaptable designs.”
Friday, 2 May 14
http://blog.testdouble.com/posts/2014-01-25-the-failures-of-intro-to-tdd.html
Fake it until you make it
“The goal of this game is to discover as
many collaboration objects as necessary
in order to define leaf nodes that
implement a piece of narrowly-defined
logic that your feature needs.”
Friday, 2 May 14
Domain discontinuity
Robert C. Martin (aka Uncle Bob) -
“First I am going to express my deep disagreement with
the Author.
I will refute his arguments and utterly destroy his
conclusions.
And then, once I'm done salting the ground where he used
to live, I'll tell you why I completely agree with him.”
http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html
Friday, 2 May 14
Domain discontinuity
Robert C. Martin (aka Uncle Bob) -
TDD works within an architectural domain
- Refactoring is cheap
- Test the behaviour not the implementation
- We won’t get it right the first time
http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html
Friday, 2 May 14
Domain discontinuity
Robert C. Martin (aka Uncle Bob) -
TDD doesn’t work across domains
- Refactoring is costly
- Moving behaviours requires new tests
- Architecture must be up-front
http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html
Friday, 2 May 14
What about architecture and design?
https://leanpub.com/software-architecture-for-developers
Friday, 2 May 14
Friday, 2 May 14
Dreyfus model of skill acquisition
http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition
Friday, 2 May 14
Intermission
Friday, 2 May 14
Friday, 2 May 14
http://www.slideshare.net/dannorth/accelerating-agile-testing
Friday, 2 May 14
http://www.slideshare.net/dannorth/accelerating-agile-testing
Friday, 2 May 14
http://c2.com/cgi/wiki?ExtremeRules
But, Dan.What about the Extreme Rules?
Friday, 2 May 14
There’s a rule to cover that...
http://c2.com/cgi/wiki?TheyreJustRules
Friday, 2 May 14
TDD
Friday, 2 May 14
Which test first?
Inside-out? - “Classicist”
Outside-in? - “London school”
In the middle? - also “Classic”
http://programmers.stackexchange.com/questions/166409/tdd-outside-in-vs-inside-out
http://martinfowler.com/articles/mocksArentStubs.html
Friday, 2 May 14
Friday, 2 May 14
Friday, 2 May 14
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, 2 May 14
Friday, 2 May 14
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, 2 May 14
Properties of unit testing
Understandable
Maintainable
Repeatable
Necessary
Granular
Fast
Friday, 2 May 14
Design for testability
- Inversion of control
- Dependency Injection
How can we test a component in isolation?
http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html
Friday, 2 May 14
http://www.jamesshore.com/Blog/Continuous-Integration-on-a-
Dollar-a-Day.html
Friday, 2 May 14
Mocking in a nutshell
Friday, 2 May 14
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, 2 May 14
Mocking can give you a false sense of security
Friday, 2 May 14
Mocking can make a terrible mess
Friday, 2 May 14
Friday, 2 May 14
- A stub in a collaboration test must correspond to
an expected result in a contract test
- An expectation in a collaboration test must
correspond to an action in a contract test
This provides a /systematic/ way to check that [your
code] remains in sync with the implementations of
[the component you are mocking].
Contract and Collaboration tests
via JB Rainsberger, GOOS mailing list,“Unit-test mock/stub assumptions rots”, 15 March 2012
Friday, 2 May 14
1. Change the implementation A1 of A, noticing a
change in the contract of A.
2. For each change in the contract of A:
1. If an action in A has changed (parameter changed,
method name changed), then look for expectations
of that action in collaboration tests, and change them
to match the new action.
2. If a response from A has changed (return type, value,
what the value means), then look for stubs of that
action in collaboration tests, and change them to
match the new response.
via JB Rainsberger, GOOS mailing list,“Unit-test mock/stub assumptions rots”, 15 March 2012
Friday, 2 May 14
Friday, 2 May 14
http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.html
Are we really writing tests?
“If somehow all your production code got deleted, but
you had a backup of your tests, then you'd be able to
recreate the production system with a little work.
“If, however, it was your tests that got deleted, then
you'd have no tests to keep the production code
clean.The production code would inevitably rot,
slowing you down.”
Friday, 2 May 14
“So we can conclude that if it became a choice
between the tests or the production code, we'd rather
preserve the tests.
“And this means that the tests are a more important
component of the system than the production code is.
“Because the tests are the specs.”
http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.html
Or are we writing specifications?
Friday, 2 May 14
What use is coverage?
Friday, 2 May 14
http://pitest.org
Mutation testing
Friday, 2 May 14
Friday, 2 May 14
Friday, 2 May 14
Friday, 2 May 14
Who do developer tests help?
- NOT the application
- NOT the customers
- The development team
(sometimes)
The tests should make your life EASIER
Friday, 2 May 14
Things that seem important to me:
- chase the VALUE
- identify the RISKS
- understand your CONTEXT
The tests should make your life EASIER
Friday, 2 May 14
http://edinburgh.bcs.org/courses
Friday, 2 May 14
http://edinburgh.bcs.org/courses
Friday, 2 May 14
Seb	
  Rose
Twi;er:	
  	
   @sebrose
Blog:	
  	
   	
   www.claysnow.co.uk
E-­‐mail:	
   	
   seb@claysnow.co.uk
Friday, 2 May 14
Backup
62
Friday, 2 May 14
Step 1
Write exactly one new test. It should be the
smallest test which seems to point in the
direction of a solution
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14
Step 2
Run the test to make sure it fails
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14
Step 3
Make the test from (Step 1) pass by writing
the least amount of implementation code you
can INTHETEST METHOD.
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14
Step 4
Refactor to remove duplication or otherwise as
required to improve the design. Be strict about
the refactorings. Only introduce new
abstractions (methods, classes, etc) when they
will help to improve the design of the code.
Specifically...
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14
Step 4 (continued)
1.ONLY Extract a new method if there is
sufficient code duplication in the test
methods.When extracting a method, initially
extract it to the test class (don't create a
new class yet).
2.ONLY create a new class when a clear
grouping of methods emerges and when the
test class starts to feel crowded or too large.
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14
Step 5
Repeat the process by writing another test
(go back to Step 1).
TDD as if you meant it
http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/
Friday, 2 May 14

Contenu connexe

En vedette

A Little Photo Essay about Intensification and infill
A Little Photo Essay about Intensification and infillA Little Photo Essay about Intensification and infill
A Little Photo Essay about Intensification and infillIan Cooper
 
Test automation is dead CoDe Copenhagen 2016
Test automation is dead   CoDe Copenhagen 2016Test automation is dead   CoDe Copenhagen 2016
Test automation is dead CoDe Copenhagen 2016Seb Rose
 
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 201610 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 2016Seb Rose
 
Planning poker in a nutshell
Planning poker in a nutshellPlanning poker in a nutshell
Planning poker in a nutshellSeb Rose
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaSeb Rose
 
Real world continuous delivery
Real world continuous deliveryReal world continuous delivery
Real world continuous deliverySeb Rose
 

En vedette (6)

A Little Photo Essay about Intensification and infill
A Little Photo Essay about Intensification and infillA Little Photo Essay about Intensification and infill
A Little Photo Essay about Intensification and infill
 
Test automation is dead CoDe Copenhagen 2016
Test automation is dead   CoDe Copenhagen 2016Test automation is dead   CoDe Copenhagen 2016
Test automation is dead CoDe Copenhagen 2016
 
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 201610 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
 
Planning poker in a nutshell
Planning poker in a nutshellPlanning poker in a nutshell
Planning poker in a nutshell
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for Java
 
Real world continuous delivery
Real world continuous deliveryReal world continuous delivery
Real world continuous delivery
 

Similaire à So long, and thanks for all the tests (Scottish Developers 2014)

DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoCasey Kinsey
 
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...Roberto Pérez Alcolea
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJohan Nilsson
 
Sprint. Don't Waterfall
Sprint. Don't WaterfallSprint. Don't Waterfall
Sprint. Don't WaterfallGiedriusTS
 
Eric Proegler Early Performance Testing from CAST2014
Eric Proegler Early Performance Testing from CAST2014Eric Proegler Early Performance Testing from CAST2014
Eric Proegler Early Performance Testing from CAST2014Eric Proegler
 
DevOps - Keepers of the Keys to the Kingdom
DevOps - Keepers of the Keys to the KingdomDevOps - Keepers of the Keys to the Kingdom
DevOps - Keepers of the Keys to the KingdomDevOpsDays Tel Aviv
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-TestingMary Clemons
 
About performance testing with NanoCloud
About performance testing with NanoCloudAbout performance testing with NanoCloud
About performance testing with NanoCloudartem_panasyuk
 
Intro to-ssdl--lone-star-php-2013
Intro to-ssdl--lone-star-php-2013Intro to-ssdl--lone-star-php-2013
Intro to-ssdl--lone-star-php-2013nanderoo
 
Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrJohn Allspaw
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigmsDean Wampler
 
Cloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug NeedhamCloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug NeedhamDoug Needham
 
Introduction to Agile Development with Scrum
Introduction to Agile Development with ScrumIntroduction to Agile Development with Scrum
Introduction to Agile Development with ScrumRenzo Borgatti
 
Fault Tolerance 101
Fault Tolerance 101 Fault Tolerance 101
Fault Tolerance 101 C4Media
 
Testing and TDD - KoJUG
Testing and TDD - KoJUGTesting and TDD - KoJUG
Testing and TDD - KoJUGlburdz
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...Marco Cedaro
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieQA or the Highway
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 

Similaire à So long, and thanks for all the tests (Scottish Developers 2014) (20)

DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
 
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & Browserify
 
Sprint. Don't Waterfall
Sprint. Don't WaterfallSprint. Don't Waterfall
Sprint. Don't Waterfall
 
Eric Proegler Early Performance Testing from CAST2014
Eric Proegler Early Performance Testing from CAST2014Eric Proegler Early Performance Testing from CAST2014
Eric Proegler Early Performance Testing from CAST2014
 
DevOps - Keepers of the Keys to the Kingdom
DevOps - Keepers of the Keys to the KingdomDevOps - Keepers of the Keys to the Kingdom
DevOps - Keepers of the Keys to the Kingdom
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
 
About performance testing with NanoCloud
About performance testing with NanoCloudAbout performance testing with NanoCloud
About performance testing with NanoCloud
 
Intro to-ssdl--lone-star-php-2013
Intro to-ssdl--lone-star-php-2013Intro to-ssdl--lone-star-php-2013
Intro to-ssdl--lone-star-php-2013
 
Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and Flickr
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigms
 
Cloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug NeedhamCloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug Needham
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
 
Introduction to Agile Development with Scrum
Introduction to Agile Development with ScrumIntroduction to Agile Development with Scrum
Introduction to Agile Development with Scrum
 
Fault Tolerance 101
Fault Tolerance 101 Fault Tolerance 101
Fault Tolerance 101
 
Testing and TDD - KoJUG
Testing and TDD - KoJUGTesting and TDD - KoJUG
Testing and TDD - KoJUG
 
Testable Code ... In Joomla!?
Testable Code ... In Joomla!?Testable Code ... In Joomla!?
Testable Code ... In Joomla!?
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 

Plus de Seb Rose

Software contracts - Global Enterprise Agile 2023.pdf
Software contracts - Global Enterprise Agile 2023.pdfSoftware contracts - Global Enterprise Agile 2023.pdf
Software contracts - Global Enterprise Agile 2023.pdfSeb Rose
 
Micro-service delivery - without the pitfalls
Micro-service delivery - without the pitfallsMicro-service delivery - without the pitfalls
Micro-service delivery - without the pitfallsSeb Rose
 
DevSecOps - Agile Get-Together 2022.pdf
DevSecOps - Agile Get-Together 2022.pdfDevSecOps - Agile Get-Together 2022.pdf
DevSecOps - Agile Get-Together 2022.pdfSeb Rose
 
Contract testing - Sealights 2022.pdf
Contract testing - Sealights 2022.pdfContract testing - Sealights 2022.pdf
Contract testing - Sealights 2022.pdfSeb Rose
 
Example mapping - slice any story into testable examples - SoCraTes 2022.pdf
Example mapping - slice any story into testable examples - SoCraTes 2022.pdfExample mapping - slice any story into testable examples - SoCraTes 2022.pdf
Example mapping - slice any story into testable examples - SoCraTes 2022.pdfSeb Rose
 
Software testing - learning to walk again (expoQA22)
Software testing - learning to walk again (expoQA22)Software testing - learning to walk again (expoQA22)
Software testing - learning to walk again (expoQA22)Seb Rose
 
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021Seb Rose
 
A brief history of requirements - Unicom 2022
A brief history of requirements  - Unicom 2022A brief history of requirements  - Unicom 2022
A brief history of requirements - Unicom 2022Seb Rose
 
Example mapping (with builds) - ProductWorld 2022
Example mapping (with builds)  - ProductWorld 2022Example mapping (with builds)  - ProductWorld 2022
Example mapping (with builds) - ProductWorld 2022Seb Rose
 
Example mapping - ProductWorld 2022
Example mapping - ProductWorld 2022Example mapping - ProductWorld 2022
Example mapping - ProductWorld 2022Seb Rose
 
No code, low code, machine code QA ATL 2021
No code, low code, machine code   QA ATL 2021No code, low code, machine code   QA ATL 2021
No code, low code, machine code QA ATL 2021Seb Rose
 
No code, low code, machine code QA ATL 2021
No code, low code, machine code   QA ATL 2021No code, low code, machine code   QA ATL 2021
No code, low code, machine code QA ATL 2021Seb Rose
 
No code, low code, machine code - Unicom 2021
No code, low code, machine code -  Unicom 2021No code, low code, machine code -  Unicom 2021
No code, low code, machine code - Unicom 2021Seb Rose
 
BDD: from soup to nuts - The Future of Work Scotland 2021
BDD: from soup to nuts  - The Future of Work Scotland 2021BDD: from soup to nuts  - The Future of Work Scotland 2021
BDD: from soup to nuts - The Future of Work Scotland 2021Seb Rose
 
Contrasting test automation and BDD - 2020
Contrasting test automation and BDD - 2020Contrasting test automation and BDD - 2020
Contrasting test automation and BDD - 2020Seb Rose
 
Are BDD and test automation the same thing? Automation Guild 2021
Are BDD and test automation the same thing?   Automation Guild 2021Are BDD and test automation the same thing?   Automation Guild 2021
Are BDD and test automation the same thing? Automation Guild 2021Seb Rose
 
"Our BDDs are broken!" Lean Agile Exchange 2020
"Our BDDs are broken!"   Lean Agile Exchange 2020"Our BDDs are broken!"   Lean Agile Exchange 2020
"Our BDDs are broken!" Lean Agile Exchange 2020Seb Rose
 
User stories: from good intentions to bad advice - Agile Scotland 2019
User stories: from good intentions to bad advice - Agile Scotland 2019User stories: from good intentions to bad advice - Agile Scotland 2019
User stories: from good intentions to bad advice - Agile Scotland 2019Seb Rose
 
User stories: from good intentions to bad advice - Lean Agile Scotland 2019
User stories: from good intentions to bad advice - Lean Agile Scotland 2019User stories: from good intentions to bad advice - Lean Agile Scotland 2019
User stories: from good intentions to bad advice - Lean Agile Scotland 2019Seb Rose
 
Software contracts or: how I learned to stop worrying and love releasing. Agi...
Software contracts or: how I learned to stop worrying and love releasing. Agi...Software contracts or: how I learned to stop worrying and love releasing. Agi...
Software contracts or: how I learned to stop worrying and love releasing. Agi...Seb Rose
 

Plus de Seb Rose (20)

Software contracts - Global Enterprise Agile 2023.pdf
Software contracts - Global Enterprise Agile 2023.pdfSoftware contracts - Global Enterprise Agile 2023.pdf
Software contracts - Global Enterprise Agile 2023.pdf
 
Micro-service delivery - without the pitfalls
Micro-service delivery - without the pitfallsMicro-service delivery - without the pitfalls
Micro-service delivery - without the pitfalls
 
DevSecOps - Agile Get-Together 2022.pdf
DevSecOps - Agile Get-Together 2022.pdfDevSecOps - Agile Get-Together 2022.pdf
DevSecOps - Agile Get-Together 2022.pdf
 
Contract testing - Sealights 2022.pdf
Contract testing - Sealights 2022.pdfContract testing - Sealights 2022.pdf
Contract testing - Sealights 2022.pdf
 
Example mapping - slice any story into testable examples - SoCraTes 2022.pdf
Example mapping - slice any story into testable examples - SoCraTes 2022.pdfExample mapping - slice any story into testable examples - SoCraTes 2022.pdf
Example mapping - slice any story into testable examples - SoCraTes 2022.pdf
 
Software testing - learning to walk again (expoQA22)
Software testing - learning to walk again (expoQA22)Software testing - learning to walk again (expoQA22)
Software testing - learning to walk again (expoQA22)
 
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021
DevSecOps - Unicom Agile and DevOps Expo (Adaptive Challenges) 2021
 
A brief history of requirements - Unicom 2022
A brief history of requirements  - Unicom 2022A brief history of requirements  - Unicom 2022
A brief history of requirements - Unicom 2022
 
Example mapping (with builds) - ProductWorld 2022
Example mapping (with builds)  - ProductWorld 2022Example mapping (with builds)  - ProductWorld 2022
Example mapping (with builds) - ProductWorld 2022
 
Example mapping - ProductWorld 2022
Example mapping - ProductWorld 2022Example mapping - ProductWorld 2022
Example mapping - ProductWorld 2022
 
No code, low code, machine code QA ATL 2021
No code, low code, machine code   QA ATL 2021No code, low code, machine code   QA ATL 2021
No code, low code, machine code QA ATL 2021
 
No code, low code, machine code QA ATL 2021
No code, low code, machine code   QA ATL 2021No code, low code, machine code   QA ATL 2021
No code, low code, machine code QA ATL 2021
 
No code, low code, machine code - Unicom 2021
No code, low code, machine code -  Unicom 2021No code, low code, machine code -  Unicom 2021
No code, low code, machine code - Unicom 2021
 
BDD: from soup to nuts - The Future of Work Scotland 2021
BDD: from soup to nuts  - The Future of Work Scotland 2021BDD: from soup to nuts  - The Future of Work Scotland 2021
BDD: from soup to nuts - The Future of Work Scotland 2021
 
Contrasting test automation and BDD - 2020
Contrasting test automation and BDD - 2020Contrasting test automation and BDD - 2020
Contrasting test automation and BDD - 2020
 
Are BDD and test automation the same thing? Automation Guild 2021
Are BDD and test automation the same thing?   Automation Guild 2021Are BDD and test automation the same thing?   Automation Guild 2021
Are BDD and test automation the same thing? Automation Guild 2021
 
"Our BDDs are broken!" Lean Agile Exchange 2020
"Our BDDs are broken!"   Lean Agile Exchange 2020"Our BDDs are broken!"   Lean Agile Exchange 2020
"Our BDDs are broken!" Lean Agile Exchange 2020
 
User stories: from good intentions to bad advice - Agile Scotland 2019
User stories: from good intentions to bad advice - Agile Scotland 2019User stories: from good intentions to bad advice - Agile Scotland 2019
User stories: from good intentions to bad advice - Agile Scotland 2019
 
User stories: from good intentions to bad advice - Lean Agile Scotland 2019
User stories: from good intentions to bad advice - Lean Agile Scotland 2019User stories: from good intentions to bad advice - Lean Agile Scotland 2019
User stories: from good intentions to bad advice - Lean Agile Scotland 2019
 
Software contracts or: how I learned to stop worrying and love releasing. Agi...
Software contracts or: how I learned to stop worrying and love releasing. Agi...Software contracts or: how I learned to stop worrying and love releasing. Agi...
Software contracts or: how I learned to stop worrying and love releasing. Agi...
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

So long, and thanks for all the tests (Scottish Developers 2014)

  • 1. So  long,  and  thanks  for  all  the   tests Seb  Rose Claysnow  Limited @sebrose Friday, 2 May 14
  • 3. “The last ever dolphin message was misinterpreted as a surprisingly sophisticated attempt to do a double-backwards-somersault through a hoop whilst whistling the 'Star Spangled Banner', but in fact the message was this: So long and thanks for all the fish.” http://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_(novel) Friday, 2 May 14
  • 4. 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, 2 May 14
  • 5. Developer tests What are they for? • making sure the code works • preventing regressions • documenting the code • driving a testable design Friday, 2 May 14
  • 6. “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, 2 May 14
  • 8. Developer testing When do you write tests? • never • after writing the code • while you write the code • before writing the code Friday, 2 May 14
  • 10. “Takes too much time to write tests.” “If I change something it will break a whole bunch of tests that I will have to fix and it will be more work for me in the end than just verifying my changes manually.” “Running the tests takes too long.” http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations Friday, 2 May 14
  • 11. “No scientific proof of it actually having any benefit (compared to just code reviews, pair programming or etc.) for the same amount of time” “It's not practical for the kind of work I do. By which I mean, it cannot be conclusively shown to provide tangible benefits that outweigh the perceived costs.” http://www.slideshare.net/sebrose/common-objections-to-tdd-and-their-refutations Friday, 2 May 14
  • 12. TDD - Where did it all go wrong? Ian Cooper - http://vimeo.com/68375232 Why are people abandoning TDD? - Test first is unproductive obstacle - Faster feedback gives the competitive advantage - It’s difficult to understand the test’s intent Friday, 2 May 14
  • 13. Accelerating agile Dan North - http://vimeo.com/68215534 Isn’t agility about speed? - Fast feedback - Understand the risk - Use appropriate methods http://programmingandthecity.wordpress.com/2013/09/30/whats-dan-north-wearing-today/ Friday, 2 May 14
  • 14. TDD is dead David Heinemeier Hansson- http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html http://david.heinemeierhansson.com/2014/test-induced-design-damage.html TDD isn’t useful anymore - We’ve learnt what we needed - Unit tests aren’t useful - Testability hurts the design Friday, 2 May 14
  • 15. Oh no it’s not Robert C. Martin (aka Uncle Bob) - TDD is still useful - Unit tests are fast and thorough - It’s not universally applicable - Decomposition is good design http://blog.8thlight.com/uncle-bob/2014/04/25/MonogamousTDD.html http://blog.8thlight.com/uncle-bob/2014/04/30/When-tdd-does-not-work.html http://blog.8thlight.com/uncle-bob/2014/05/01/Design-Damage.html Friday, 2 May 14
  • 16. Queuing theory JB Rainsberger - http://www.jbrains.ca/permalink/how-test-driven-development-works-and-more Given a process B, which follows a process A, sometimes in performing B we need to perform some of A again. We can remove the need to rework by taking some portion of process B and performing it before process A Friday, 2 May 14
  • 17. “With emergent design, a development organization starts delivering functionality and lets the design emerge. ...while it is being built, the organization will [...] refactor out the commonality ... At the end [we are] left with the smallest set of the design needed, as opposed to the design that could have been anticipated in advance.” Emergent design http://en.wikipedia.org/wiki/Emergent_Design Friday, 2 May 14
  • 18. http://effectivesoftwaredesign.com/2013/10/18/avoiding-technical-debt-how-to-accumulate-technical- savings/ Adaptable design up-front? “... software systems must evolve, and that this evolution must be supported through well planned, adaptable designs.” Friday, 2 May 14
  • 19. http://blog.testdouble.com/posts/2014-01-25-the-failures-of-intro-to-tdd.html Fake it until you make it “The goal of this game is to discover as many collaboration objects as necessary in order to define leaf nodes that implement a piece of narrowly-defined logic that your feature needs.” Friday, 2 May 14
  • 20. Domain discontinuity Robert C. Martin (aka Uncle Bob) - “First I am going to express my deep disagreement with the Author. I will refute his arguments and utterly destroy his conclusions. And then, once I'm done salting the ground where he used to live, I'll tell you why I completely agree with him.” http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html Friday, 2 May 14
  • 21. Domain discontinuity Robert C. Martin (aka Uncle Bob) - TDD works within an architectural domain - Refactoring is cheap - Test the behaviour not the implementation - We won’t get it right the first time http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html Friday, 2 May 14
  • 22. Domain discontinuity Robert C. Martin (aka Uncle Bob) - TDD doesn’t work across domains - Refactoring is costly - Moving behaviours requires new tests - Architecture must be up-front http://blog.8thlight.com/uncle-bob/2014/01/27/TheChickenOrTheRoad.html Friday, 2 May 14
  • 23. What about architecture and design? https://leanpub.com/software-architecture-for-developers Friday, 2 May 14
  • 25. Dreyfus model of skill acquisition http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition Friday, 2 May 14
  • 30. http://c2.com/cgi/wiki?ExtremeRules But, Dan.What about the Extreme Rules? Friday, 2 May 14
  • 31. There’s a rule to cover that... http://c2.com/cgi/wiki?TheyreJustRules Friday, 2 May 14
  • 33. Which test first? Inside-out? - “Classicist” Outside-in? - “London school” In the middle? - also “Classic” http://programmers.stackexchange.com/questions/166409/tdd-outside-in-vs-inside-out http://martinfowler.com/articles/mocksArentStubs.html Friday, 2 May 14
  • 36. 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, 2 May 14
  • 38. 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, 2 May 14
  • 39. Properties of unit testing Understandable Maintainable Repeatable Necessary Granular Fast Friday, 2 May 14
  • 40. Design for testability - Inversion of control - Dependency Injection How can we test a component in isolation? http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html Friday, 2 May 14
  • 42. Mocking in a nutshell Friday, 2 May 14
  • 43. 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, 2 May 14
  • 44. Mocking can give you a false sense of security Friday, 2 May 14
  • 45. Mocking can make a terrible mess Friday, 2 May 14
  • 47. - A stub in a collaboration test must correspond to an expected result in a contract test - An expectation in a collaboration test must correspond to an action in a contract test This provides a /systematic/ way to check that [your code] remains in sync with the implementations of [the component you are mocking]. Contract and Collaboration tests via JB Rainsberger, GOOS mailing list,“Unit-test mock/stub assumptions rots”, 15 March 2012 Friday, 2 May 14
  • 48. 1. Change the implementation A1 of A, noticing a change in the contract of A. 2. For each change in the contract of A: 1. If an action in A has changed (parameter changed, method name changed), then look for expectations of that action in collaboration tests, and change them to match the new action. 2. If a response from A has changed (return type, value, what the value means), then look for stubs of that action in collaboration tests, and change them to match the new response. via JB Rainsberger, GOOS mailing list,“Unit-test mock/stub assumptions rots”, 15 March 2012 Friday, 2 May 14
  • 50. http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.html Are we really writing tests? “If somehow all your production code got deleted, but you had a backup of your tests, then you'd be able to recreate the production system with a little work. “If, however, it was your tests that got deleted, then you'd have no tests to keep the production code clean.The production code would inevitably rot, slowing you down.” Friday, 2 May 14
  • 51. “So we can conclude that if it became a choice between the tests or the production code, we'd rather preserve the tests. “And this means that the tests are a more important component of the system than the production code is. “Because the tests are the specs.” http://blog.8thlight.com/uncle-bob/2013/09/23/Test-first.html Or are we writing specifications? Friday, 2 May 14
  • 52. What use is coverage? Friday, 2 May 14
  • 57. Who do developer tests help? - NOT the application - NOT the customers - The development team (sometimes) The tests should make your life EASIER Friday, 2 May 14
  • 58. Things that seem important to me: - chase the VALUE - identify the RISKS - understand your CONTEXT The tests should make your life EASIER Friday, 2 May 14
  • 61. Seb  Rose Twi;er:     @sebrose Blog:       www.claysnow.co.uk E-­‐mail:     seb@claysnow.co.uk Friday, 2 May 14
  • 63. Step 1 Write exactly one new test. It should be the smallest test which seems to point in the direction of a solution TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14
  • 64. Step 2 Run the test to make sure it fails TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14
  • 65. Step 3 Make the test from (Step 1) pass by writing the least amount of implementation code you can INTHETEST METHOD. TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14
  • 66. Step 4 Refactor to remove duplication or otherwise as required to improve the design. Be strict about the refactorings. Only introduce new abstractions (methods, classes, etc) when they will help to improve the design of the code. Specifically... TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14
  • 67. Step 4 (continued) 1.ONLY Extract a new method if there is sufficient code duplication in the test methods.When extracting a method, initially extract it to the test class (don't create a new class yet). 2.ONLY create a new class when a clear grouping of methods emerges and when the test class starts to feel crowded or too large. TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14
  • 68. Step 5 Repeat the process by writing another test (go back to Step 1). TDD as if you meant it http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/ Friday, 2 May 14