Testing Poncho Projects Directly
Let’s test our poncho project’s persistence.
We'll cover the following
The tests we’ve written so far are not enough. We need to isolate the most complex elements of our boundary and test those layers independently. Let’s dive into the test for our poncho project and build some basic tests for MasteryPersistence
that cover basic corner cases such as error conditions.
As we build our poncho dependencies, they’ll need testing just like our other solutions do. Testing is essential for boundary concerns, as those code paths will need to embrace the chaos inherent in external dependencies, timing-based error conditions, and the complexity inherent in systems that allow mutability. Boundaries encapsulate many of the properties that make our programs the most useful.
Our testing plan
The MasteryPersistence
codebase is a pretty shallow, with a clear API for its most important features. We’ll focus all of our energy testing that API. We’ll put all of our tests in a single file, with the understanding that we can break up that file should we need to do so.
Since the project doesn’t have a complex schema, we won’t need to build any test fixtures. We’ll be able to get away with the following:
-
Basic setup for all tests.
-
Independent tests for each concept we want to test.
We’ll crack open /mastery_persistence/test/mastery_persistence_test.exs
and key this in. We’ll follow the entire flow and then run the tests:
Get hands-on with 1200+ tech skills courses.