[erlang-questions] EUnit

Andrew Stone stondage123@REDACTED
Tue Mar 11 17:41:22 CET 2008

Thank you very much Hasan. I also noticed that there is an examples directory in the eunit source. I should've given that a look first :)

One more question: I put some io:format statements in my setup and cleanup functions but they don't show up. Does that mean they aren't being run properly? Do I need to run something like 'eunit:setup()' first?

Also, after some experimentation, I found that a simple way to run all tests in the current directory is eunit:test(".").


----- Original Message ----
From: Hasan Veldstra <hasan.veldstra@REDACTED>
To: erlang-questions@REDACTED
Sent: Tuesday, March 11, 2008 3:00:12 AM
Subject: Re: [erlang-questions] EUnit

Andrew Stone wrote:
> Thanks Richard. But I'm still having a little trouble. What I meant was how do I create a fixture etc...?

Here's an example of a simple fixture:

simple_test_() ->
    {setup, local,
     fun setup/0,   %% This is called before the tests are run (to set
up things).
     fun cleanup/1, %% This is called after the tests have been run
(to clean up).
     fun(List) ->   %% The argument to this is the return value of setup().
              ?_assert(2*2 == 4),
              ?_assert(not(true) == false)

I agree, the docs are a bit cryptic and it took me a wee while to figure it out.

erlang-questions mailing list

More information about the erlang-questions mailing list