Negative Testing: Broad Properties
Understand how to design broad properties for negative testing in PropEr with Elixir. Learn to test more general behaviors beyond happy paths to reveal hidden errors. See how to patch implementations for clearer error handling and improve your confidence in code correctness.
We'll cover the following...
Negative tests
An interesting aspect of the code and tests we have written so far is that the list of items being bought is generated through the list of supported items. Designing the test case from the price list shows a lack of tests looking for unexpected use cases. Our tests are positive, happy-path tests, validating that everything is operating as it should. Negative tests, by comparison, try to specifically exercise underspecified scenarios to find what happens in less happy paths.
Our current properties are good. We don’t want to modify them or make them more complex. Instead, we’ll write a few broad properties that test more general properties of the code and see if the requirements we had in place are actually consistent. ...