I sometimes see the claim that with a sufficiently strong type system applied properly, there’s almost no need for unit tests and less need for automated testing in general: if the code compiles, there’s little opportunity for it to be incorrect. That’s appealing and I can see how it’s true in some cases. But I struggle to see how it’d really apply to some of the projects I’ve worked on. I’m curious to hear stories from people who’ve become convinced of the truth of that claim. Were there any resources that helped you get there? Anything that finally made it click for you? Here are some examples of styles of tests in my current code base’s test suite that I can’t see how I’d represent as compile-time type checks no matter how sophisticated the type system was. For context, this particular code base uses a CQRS-style, event-sourcing architecture, and it’s part of a payment service.
Can all the historical versions of all the events be deserialized correctly from the event store, getting converted to newer versions (or to completely different event types) as needed? Does the XML we send to a third-party service validate successfully with their schema? Is timeout logic executed when expected user actions don’t occur in the required amount of time? Do our fee calculations produce the values listed in the examples in our product spec? Do we correctly throttle our outgoing requests when a remote service starts responding slowly?