[erlang-questions] I Hate Unit Testing...

pax watson.timothy@REDACTED
Thu Jan 29 00:18:05 CET 2009


>> In addition, eunit's ?debugVal() macro is incredibly useful -- it's
>> like the keystroke-friendly print stmt that Erlang doesn't have.  In
>> other words, one of your tests fail -- want to look at what's going  
>> on
>> inside the middle of a function somewhere?  Just wrap a line in ?
>> debugVal() and you get a *great* info message, with full line number
>> and everything.  It's so useful I sometimes -include eunit just to  
>> get
>> access to that during my dev process.
>
> I was thinking that the debug macros and the plain assert macros  
> should
> probably be made available directly from their own respective header
> files as well, but haven't got around to doing that yet.

Oooooh - yes please. Although I use common_test exclusively (for  
reasons I mentioned in a previous post), I usually include the eunit  
header so I can make use of your plain assertions. More recently I've  
been writing test code that borrows the 'matcher' concept from  
hamcrest, so

?assertThrows(....)

looks more like

expect_that(fun() -> ... end, should_fail({throw, ExpectedData})).

This just returns 'true' or {failed, Reason} however, so I wrap it in  
a macro that uses eunit ?assert anyway! ;)

> Steve Davis wrote:
>> Almost, but significantly... not quite. No compile step.
>
> Hm, well, you've heard of this nifty thing called "make"?
> But agreed, it is an additional step.

Agree with this and also using an Emakefile can keep things simple  
too. Another reason I use common_test is that it automatically  
compiles your test modules for you and you don't need to even bother  
with an Emakefile:

erl -sname ct -pa ./ebin  -s ct_run script_start -s erlang halt -I  
include  -logdir ./test/logs -dir test -cover coverage.spec

All the business of identifying which modules contain tests (those  
that follow the <name>_SUITE convention or are listed in a test  
specification file), compiling them and so on, is done for me. Again  
this is why I'm slightly baffled that everyone thinks common_test is  
too complicated - it is the perfect complement to eunit IMO.




More information about the erlang-questions mailing list