🚀 TDD, Where Did It All Go Wrong (Ian Cooper)
DevTernity Conference11 HN recommenders · recommended in 11 months, 2018–2024
talk · intermediate · evergreen · 2018–2024 on HN
Ian Cooper's DevTernity talk revisits Kent Beck's original TDD ideas and shows where misunderstandings crept in. It argues tests should target behaviors through public interfaces rather than implementation details, so suites support refactoring instead of res…
HN repeatedly calls it the best talk on testing, and many say it changed how they approach tests, mocks and the meaning of a unit.
Up next
3 mo on HNthat dark matter video aged like milk
Angela Collier
3 HN recommender · 2024–2024
4 mo on HNdark matter is not a theory
Angela Collier
5 HN recommender · 2023–2024
3 mo on HNProcedural Programming: It Never Went Away — Kevlin Henney | Build Stuff
Build Stuff - #1 Software Dev Conf
2 HN recommender · 2018–2021
7 mo on HNBottom Up vs Top Down Design in Clojure - Mark Bastian
ClojureTV
5 HN recommender · 2016–2021
14 mo on HN"Simple Made Easy" - Rich Hickey (2011)
Strange Loop Conference
14 HN recommender · 2022–2026
3 mo on HNCharlie Marsh: uv: An Extremely Fast Python Package Manager
Jane Street
3 HN recommender · 2024–2025
3 mo on HNUnderstanding the Toyota RAV4 Hybrid
WeberAuto
3 HN recommender · 2023–2026
4 mo on HNDavid Beazley - Lambda Calculus from the Ground Up - PyCon 2019
PyCon 2019
4 HN recommender · 2019–2021
15 mo on HNRailsConf 2014 - All the Little Things by Sandi Metz
Confreaks
15 HN recommender · 2015–2025
11 mo on HN"Testing Distributed Systems w/ Deterministic Simulation" by Will Wilson
Strange Loop Conference
12 HN recommender · 2014–2024
11 mo on HNBret Victor - Inventing on Principle
Rui Oliveira
12 HN recommender · 2013–2025
11 mo on HNSolving Problems the Clojure Way - Rafal Dittwald
Clojure/north
10 HN recommender · 2019–2025
12 comments from Hacker News
This the best talk I've ever seen about testing (Ian Cooper): ▶ this video I see he's done a much more recent follow up, which I intend to watch: link Not sure if it contains new ideas. He says the unit is not "a class" but a module. It's up to you to decide what the module does (ie. what level of abstraction it's at). More importantly, he argues against mocking and essentially "unit testing" in most cases.
Ian Cooper talked about this (and more) 5 years ago: ▶ this video Well worth listening to this talk. It completely changed the way I did testing.
> Firstly if the dependency isn't doing any io, you can test your code as a whole along with its dependency. No need to mock. This the thing. People have a tendency to overuse mocks. The point of automated testing (whether it's unit tests or something else), is to enable refactoring. That's really the only reason. Code that you don't touch doesn't suddenly change its behaviour one day. In a previous jobs the developers started to go crazy with mocking and it reached a kind of singularity where essentially if a function called anything, that thing was mocked. It definitely tests each function in complete isolation, but what's the point? It makes refactoring impossible, which is the entire point of the tests in the first place! This excellent talk completely changed the way I approached testing. Every developer who writes tests needs to watch this now! ▶ this video
The best talk on this topic, IMO is Ian Cooper: "TDD, Where did it all go wrong?" ▶ this video Couple of notes: - TDD, much like scrum, got corrupted by the "Agile Consulting Industry". Sticking to the original principles as laid out by Kent Beck results in fairly sane practices. - When people talk about "unit tests", a unit doesn't refer to the common pattern of "a single class". A unit is a piece of the software with a clear boundary. It might be a whole microservice, or a chunk of a monolith that is internally consistent. - What triggers writing a test is what matters. Overzealous testers test for each new public method in a class. This leads to testing on implementation details of the actual unit, because most classes are only consumed within a single unit. - Behavior driven testing makes most sense to decide what needs tests. If it's required behavior to the people across the boundary, it needs a test. Otherwise, tests may be extraneous or even harmful. - As such, a good trigger rule is "one test per desired external behavior of the unit, plus one test per bug fixed". The test for each bugfix comes from experience -- they delineate tricky parts of your unit and enforce workign code around them.
'Test Pyramid' considered harmful IMO. It discourages people from writing tests against the public interface of their system , and instead encourages testing against internals. This leads to a test pack that prevents refactoring, and can't be trusted to catch regression errors. This is partly down to the widely confused definition of a 'unit test' (which a lot of people interpret as 'one test per class'). If you haven't seen it, please watch Ian Cooper's "TDD, Where Did It All Go Wrong" ▶ this video Also, I thought continuous testing was having your test pack run all the time while coding, but hey ho.
I'm curious if you've seen Ian Cooper's excellent talk, "TDD, Where Did It All Go Wrong?" ▶ this video One of his key points is that throwaway test code is only a problem if you neglect to throw it away.
That's why TDD is about testing requirements and not implementations. The problem is most people dont know what TDD is: ▶ this video
There's a middle tier, broad tests in the sense of not mocking local dependencies but only external (slow) ones. Many developers mock every dependency in a SUT, even if they own the dependency. I like the idea of broad tests that run-in memory (no I/O interaction). I think Ian Cooper does a great work explaining it in this talk (he talks about TDD, but I think the main idea applies even if you write tests after code): ▶ this video
That's the right way to do TDD, see this talk: ▶ this video One of the above comments mentions BDD as a close cousin to TDD, but that is wrong as TDD is actually BDD as you should only be testing behaviours, which allow you to "fearlessly refactor"
IMO, a lot of sage advice about TDD, well informed by years of practice, is in two Ian Cooper NDC talks, his controversial-at-the-time "TDD, Where Did It All Go Wrong?"[1] and, seven years later, "TDD Revisited"[2]. The blurb from the latter: > In this talk we will look at the key Fallacies of Test-Driven Development, such as 'Developers write Unit Tests', or 'Test After is as effective as Test First' and explore a set of Principles that let us write good unit tests instead. Attendees should be able to take away a clear set of guidelines as to how they should be approaching TDD to be successful. The session is intended to be pragmatic advice on how to follow the ideas outlined in my 2013 talk "TDD Where Did it All Go Wrong" The talks focus on reasons to avoid slavish TDD and advocate for the benefits of judiciously applying TDD's originating principles. 1: ▶ this video 2: link
You are doing interface/function level testing and calling it unit testing. That's what industry converged on, that a function/method = a unit, but it apparently used to be that a module meant to be a unit. It can be that both interfaces and modules can be considered a "bag of functions". Seems like a lot of confusion about unit testing, mocking and DI stems from this historical shift. I believe that interface/method level testing is too granular and mostly results in overfitted tests. Testing implementation, not behaviour. Which can be useful for some algorithm package for example, but probably not so much applicable to typical business logic code. TDD: where did it all go wrong. ▶ this video
Just don't use them unless you have to. The two main reasons to mock are for network requests and because something is too slow. Other than that, test things for real. Do not isolate parts of your code from other parts of your code by using mocks. If your code does side effects on your own machine, like writes to the file system, let it write to a temporary directory. I linked this excellent talk in another thread recently. I'll put it here again: ▶ this video