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

Richard Carlsson richardc@REDACTED
Wed Jan 28 16:13:41 CET 2009


Dan Milstein wrote:
> [If putting tests in that same module is somehow Wrong And Terrible,  
> world, please let me know why... ]

How terrible it is depends on who you ask, but: A) when you get a lot of
test code, it tends to clutter up the module - but for testing the
nonexported stuff, it must be in the same module (if you get a big
chunk of fairly independent code with lots of tests, it is probably
a sign that it should be broken out into another module); and B) it
means it's not real "black-box" testing, hence it's instictively
frowned upon by some - the problem being that you might not test
the right things because you can peek at how it seems to work. It's
mostly a matter of knowing what you are doing (and what you might
possibly not be doing).

> 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.

> Just my $.02 as a test-obsessed programmer: eunit is as impressively  
> close to the ideal of As Simple As Possible as anything I've ever seen.
> 
> (Speaking of which, Richard, eunit is absolutely the bomb -- I adore  
> it).

Thanks! :-)

I'm currently trying to rework some of the internals regarding the
handling of progress information, timeouts, etc., and it's pretty
tricky. In fact, eunit might look simple on the outside, but the
process handling is definitely the hairiest concurrent stuff I've
ever written - there's a lot of effort needed to be as transparent
as possible with respect to the code under test. <gumby>My brain
hurts!</gumby>

     /Richard



More information about the erlang-questions mailing list