4 ms·
Contracts and Invariants don't replace unit tests, they're complementary This is the big mix up with DbC in general I think. Think of it more like sanity-tests
by gavinray 4y ago
Contracts and Invariants don't replace unit tests, they're complementary
This is the big mix up with DbC in general I think. Think of it more like sanity-tests and assertions that help ensure your program isn't in some haywire state.
A good example with the BTree is that the invariants ensure the properties are enforced at runtime, but you still need test to invoke those properties.
These sorts of invariants mix really well with property-style tests:
You write some declarative specification for a set of boundaries on inputs/outputs, and then subject your classes to the generated inputs. If your tests pass, then all your invariants have held and you know at the bare minimum, the data structures are doing what you intend them to do.
Above that you can do load-testing and subject the invariants to scale-factors.
- MuffinFlavored 4y agoDbC?
- andreareina 4y agoDesign by Contract