Learn to test the untestable
Folks, Property-Based Testing is powerful. It can test what is typically considered untestable.
Do you have heisenbugs that only pop up occasionally but you can't reproduce them? Having trouble testing your distributed system? What about making sure that your code is thread-safe?
Property-Based Testing can do that.
In this course, which builds on what we learned in the Intermediate course, we tackle the toughest kinds of systems you can find.
- How to test input that is almost correct, not just random, incorrect input.
- How you can generate tests even when generating inputs is impossible and you don't know what the output should be
- Testing parallel systems to make sure they are thread-safe
- Testing distributed systems to find heisenbugs
- Taking a user's bug report and using PBT to reproduce it on your machine
Advanced Property-Based Testing with test.check
Want this course?Advanced Clojure: An Eric Normand Signature Course
Love it or leave it guarantee
If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.
1. Building complex generators: mutation testing
Sometimes you want to test values that are almost right. Random values won't cut it. What you can do is to generate correct values and mess them up. That's called mutation testing, and it's what we look at in this lesson.
2. Strategies for properties: metamorphic properties
Sometimes you need to test something that doesn't have a right answer. Metamorphic properties let you test a system against itself. If you modify the input, you should see a modification of the output.
3. Testing parallel systems
Parallel systems sharing state introduce the possibility of race conditions. Property-based testing can suss out race conditions in our code. In this lesson, we see the techniques used to do that.
4. Testing distributed systems
Distributed systems are hard. Testing distributed systems is hard. But at least Property-based Testing gives us a way to do it.
In this lesson, we test a distributed system. We learn:
- how to use PBT to guide our model development
- how to gain introspection into failing tests
- how to generate reliable failures—test cases that fail every time so you can use them to debug
5. When to test: to reproduce a known bug
Property-Based Testing lets you search for a sequence of operations that reproduce a bug. Imagine you get a bug report from a user or you find an exception in your logs. You don't know where it's coming from, but you know it's in your database code. How do you find that bug?
PBT lets you do a search over possible sequences of operations. You can design a test to only fail if it finds the same exception. Once you find a failing case, you can turn it into a regular regression test so you don't need to do the search again.