From 4f4a3d3f666c91a2ee2d5c12ded9d4b1ba2a8738 Mon Sep 17 00:00:00 2001 From: Joseph Hale Date: Tue, 13 Jan 2026 22:02:46 -0700 Subject: [PATCH] feat: How I Write Tests --- _posts/2025-12-14-how-i-write-tests.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 _posts/2025-12-14-how-i-write-tests.md diff --git a/_posts/2025-12-14-how-i-write-tests.md b/_posts/2025-12-14-how-i-write-tests.md new file mode 100644 index 0000000..91b4f47 --- /dev/null +++ b/_posts/2025-12-14-how-i-write-tests.md @@ -0,0 +1,26 @@ +--- +layout: post +title: How I Write Tests +tags: + - Testing + - Test Driven Development + - Unit Testing + - Code Review + - Teaching +--- + +I tend to like writing tests more than the average Joe. For me, there's something really satisfying about using a test to figure out how I want an API surface to feel, iterating on the failing test until the error message is exactly what I want to see in the test log if the feature breaks, then implementing the feature and seeing the test pass as expected, followed by refining both the implementation and test code to a state that I'd be happy to revisit/reread in 2 years. + +I tend to use mocks sparingly. e.g. I consider the persistence layer of a service part of its private internal implementation that shouldn't be tested/mocked directly. That means full DB transactions and file system access. I will however stub out external network access and return hand crafted responses for third party APIs (great for testing handling of error cases like rate limits) + +But I don't write tests first for everything, especially when I'm working with a brand new tool/language. There's a space for exploration to figure out what's possible before I pivot to testing to nail down/refine a durable approach. + +The two videos below are probably favorites about software testing. Each provides nice mental frameworks that make testing feel more strategic/expressive. + +[Sandi Metz: The Magic Tricks of Testing](https://www.youtube.com/watch?v=URSWYvyc42M) + + + +[Kevlin Henry: Structure and Interpretation of Test Cases](https://www.youtube.com/watch?v=MWsk1h8pv2Q) + + \ No newline at end of file -- 2.51.2