🎉 End-of-year Sale! Save 25% when you subscribe today.

Better Test Dependencies: Exhaustivity

Episode #138 • Mar 15, 2021 • Subscriber-Only

We talk about dependencies a lot on Point-Free, but we’ve never done a deep dive on how to tune them for testing. It’s time to do just that, by first showing how a test can exhaustively describe its dependencies, which comes with some incredible benefits.

Previous episode
Better Test Dependencies: Exhaustivity
Next episode
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

We have talked about dependencies on Point-Free a bunch. Some of first episodes were about the concept of “dependency injection made easy.” In those episodes we claimed that a lot of the complexities of dependencies can be alleviated by embracing structs instead of protocols and by coalescing all dependencies into a single mutable value.

We took these ideas further by showing how dependency injection can be made composable and modular with the Composable Architecture. The notion of dependencies was baked directly into the core unit that powers a feature, known as a reducer, and from that we got all types of benefits, such as isolating our features into their own modules, sharing dependencies between isolated features, and even using different versions of a dependency for the same screen depending on the context it was presented. There was a lot of cool stuff we explored in those episodes.

And then most recently we kicked things up a notch again when we did a deep dive into how to design dependencies. That is, how do we allow 3rd party code run in our applications without it running amok. The more 3rd party code you drop into your code base the more chances there are to make your code untestable, strain the build systems, and accidentally break things like SwiftUI previews or even the ability to run in the simulator.

We want to continue this theme a bit more because there’s still something we haven’t spent a ton of time on, and that’s how to best wield our dependencies in tests. One of the main selling points of controlling dependencies is that it allows us to easily write tests for our features. But the power of those tests largely depends on we make use of the test dependencies, and there are some really cool tricks we can employ to increase the value of our tests.

Testing features with dependencies


References

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing