[erlang-questions] PropEr testing of a fixed set of atoms
Jay Nelson
jay@REDACTED
Tue Jun 3 17:54:43 CEST 2014
On Jun 3, 2014, at 4:29 AM, Samuel <samuelrivas@REDACTED> wrote:
> Hi,
>
> Why are you using proper at all for this task? If you want exhaustive
> testing, just write a tests that goes over all the alternatives. Using
> eunit:
>
> new_dict_test_() ->
> DictTypes = [vbisect, dict, orddict],
> [ ?_assert(valid_empty_dict(T, my_dict_module:new(T))) || T <- DictTypes].
>
Several reasons:
1) I believe unit testing is too brittle and attached to the code written
2) I prefer to use a single technique where comprehensive
3) I want to avoid repeating the list of valid datatype atoms (which occur in -type)
4) I am using PropEr for other property tests as my main tool
5) PropEr already knows about my type declarations
Because of my experience on several projects with #1 I’ve stopped
using xUnit tools. Several years ago I adopted common_test over
eunit. Now I am looking to improve my coverage in a more general
fashion and I run PropEr from within common_test with cover to aid
in detecting code that my property tests overlook. I also believe thinking
in property-based testable terms leads to a better code architecture
over unit-testing specific functions.
PropEr has built-in generators that already enumerate the datatypes,
but select randomly from them when generating test cases. In the case
of a fixed, limited set of enumerables, it should be an obvious property
to test them all. I just thought I was missing something in the
documentation that allowed controlling the randomness without
jumping through hoops to create filters and a dictionary of already
seen values.
jay
More information about the erlang-questions
mailing list