One of the most useful skills I learned when using Erlang was stateful property testing, but I also learned a lot about real-world distributed systems generally.
Last week I told a coworker about my time using Erlang and he thought I needed to get a room (with Erlang).
Conversation
Replying to
Yes (thanks for asking). Simple property-based tests (sounds like you know this but just for review) is something like testing associativity, commutativity, some kind of identity (e.g. \s -> reverse (reverse s) === s), or something like that. (cont)
1
1
Stateful properties are the interleaving of operations and the properties /across/ or pre/post the set of (usually) ordered operations. E.g.,
\params -> do
id <- post params
resource <- get id
assertEquals params (Success resource)
1
4
I totally screwed this up which I now see after the three glasses of wine have worn off.
assertEquals (Success params) resource
Is probably more apt. :)
1
Replying to
Yeah I figured something was off but I only press like buttons after consumption :) In your example I don't really see the difference between the system under test and the test.
Replying to
Maybe words would be better. So let's say we have a REST API over HTTP. We have a way to create a new resource (POST /collection), after we create a new resource we expect to be able to fetch that resource (GET /collection/:id) successfully with the same attributes to create.
1
That would be one property that spans multiple operations and requires states to hold over from one op to the other. Another property might be that after creating a valid resource we should be able to successfully delete it and then when we go to fetch *after* delete we get 404.
2
Show replies

