Testing Specials
Explore how to test special pricing scenarios in property-based testing using PropEr. Understand how to build dynamic generators for regular and special items, merge them, and validate expected prices with consistent and predictable test cases.
We'll cover the following...
Getting started
Rather than modifying the existing property, which does a fine job of checking non-special prices, we’ll add a new one to check specials. The separation will help narrow down problems when they happen. If the property for basic prices always works, then we’ll know that failures in the separate special property likely relate to bugs in the special one’s handling.
Let’s take a look at the property that we could implement.
property "sums including specials" do
forall {items, expected_price, prices, specials}
<- item_price_special() do
expected_price == Checkout.total(items, prices, specials)
end
end
This property is similar to the one we wrote earlier, except that we now expect another term ...