4 ms·
Isn't unit testing a subset of property testing? Seems like a unit test tests specific input and property testing tests more than one input.
by djoldman 1y ago
Isn't unit testing a subset of property testing?
Seems like a unit test tests specific input and property testing tests more than one input.
- skybrian 1y agoYes, but converting a test to be data-driven adds some complexity (how do you debug just the failures?) and generating the inputs randomly makes it harder to know what properties to assert. Also, if you never look at the test data, it might give you false confidence about how thoroughly your code is being tested.
- stonemetal12 1y agoYes, Property testing is a generalization of unit testing.
- andreareina 1y agoThey’re different, complementary approaches. Example based testing has a known input and output. Unless you have an oracle (not usually the case) you won’t know the exact output you should get from a generated input. So instead you depend on something that should be true no matter the input. e.g. if you have a serialize/deserialize pair then `deserialize(serialize(x))` better equal `x`.
- Jtsummers 1y agoSort of. But you can also use PBT for integration and end-to-end testing, too. A user tries to schedule something and it's overlapping with an existing event, what happens? A user adds 10 events with their various requirements (none overlapping) do they successfully schedule? Set the expectations and model the expected behavior, verify that the system matches that expectation. The approach works at all testing scales.
- chriswarbo 1y agoYes, if you've got a mixture of unit tests and property tests then you can write them all using a single PBT framework, rather than needing two test frameworks.