Limits of Property-Based Testing
Understand how property-based testing checks code invariants using varied inputs but might miss incorrect implementations that preserve these invariants. Learn why combining property tests with targeted example-based tests is essential to catch corner cases and guarantee code correctness in Elixir applications.
We'll cover the following...
A property verifies invariants of our code, that is, properties of our code that stay the same regardless of the input. Sometimes, the wrong code can maintain the same invariants that we’re testing.
Are properties enough to ensure that our code works and behaves correctly?
Example
Let’s see an example. Imagine we have a property that asserts that when we concatenate two strings, then we can use String.contains?/2 to verify that the concatenated string contains both the ...