[erlang-questions] QuickCheck

Anthony Molinaro anthonym@REDACTED
Sun May 22 08:15:59 CEST 2011


On Sun, May 22, 2011 at 08:01:09AM +1000, Edmond Begumisa wrote:
> I'm a QuickCheck noob trying out PropEr. Actually, I'm very
> embarrassed to admit that I'm very new to formal testing in general
> (I've always done things in the ad-hoc way for longer than I care to
> admit). I only confess to this coz I probably wouldn't get away with
> lying about it on *this* list when I start asking stupid questions!

I'm mostly a noob myself, but I have used both quickcheck and proper
and figured anything helps when you're just learning these tools.

> Anyways, I'm having A LOT of trouble getting started. The initial
> inertia just isn't there. Even with the available documentation from
> both QuviQ and PropEr. I look at my code and don't know where to
> begin writing tests for it! A sad state of affairs.

The one thing to remember is that there are many types of testing
and quickcheck/proper focus on randomized testing of properties.
Getting you head around testing in that fashion can be a challenge,
it forces you to think about generating random data for which you
know the answer.  Quickcheck and proper excel at problems where
you have a function and it's reverse (like encode and decode), because
the property of decode (encode (Data)) == Data is pretty easy to setup,
you just supply random Data and let it run for a few hundred thousand
tests.  For other functions where you don't have an inverse the trick
is knowing the answer when you give it random data (at least this
is what I've found with my limited use of these tools).

Other testing frameworks like eunit or common_test may be more of
what you are looking for, but it really depends on what you are
testing.  If you have a general description of the code, I might
be able to make some suggestions, but its hard to say without
know what you are trying to test.

> I think I just need a few good tutorials. Can anyone recommend some
> QuickCheck resources to get me going that they've actually
> successfully used? Do I need to first start out with more
> "traditional" testing tools first before even attempting QuickCheck?

There are a few nice examples here

http://www.trapexit.org/Category:QuickCheck

There are also a few videos and other things if you search for
erlang quickcheck tutorial on your favorite search engine.

Hope that helps,

-Anthony


-- 
------------------------------------------------------------------------
Anthony Molinaro                           <anthonym@REDACTED>



More information about the erlang-questions mailing list