"All you need are types!" vs "All you need are tests!". Types catch one type of error. Tests catch a different type. Both can help build quality software. When I talk about observability and testing in production, sometimes I get pushback: "This is a failure of unit testing!" "Are you saying we don't need as to test locally?!" "Unit testing is the bomb!" OK, maybe not that last one, although I do agree. It's not "unit testing vs observability - FIGHT!". Types catch certain errors. Tests catch certain errors. Observability allows us to understand certain errors. The fact is - production software is usually so complex that we can't reason about it without seeing it run, for real, with real users and real workloads. Not only does observability allow us to reason about errors... ...it gives us a broader understanding of our app. Who's using that new feature we just pushed? Is it too slow? Are customers using the app more because of our feature? Or less? There are a bunch of metrics that don't show up in any error tracking software, but they're actionable all the same. I'm LIVE on LinkedIn tomorrow with Denis Čahuk - comment LIVE below if you want a link!
The key point with tests is that they are FAILING tests. Any test begins its life by failing. How do you implement failing types?
I've gone further. Types are a quick and easy solution to 3/4 of the problems relating to data types. Tests are better.
Why not both?
I never understood this false dichotomy between testing and types. On one side, people who claim that type systems make testing unnecessary (bullshit); on the other, people who say that testing makes types useless (bullshit). The reality is: we cannot build reliable, high-quality, safe systems without tests, whether we use static or dynamic type systems. Types are useful. Just not sufficient.
Helping Engineers Understand Apps In Production
5dI'm going live tomorrow - here's the link folks! https://www.linkedin.com/events/observabilityadviceforbusyteams7388914286271725568/theater/