[erlang-questions] test driven development

Håkan Stenholm <>
Sun Nov 25 04:40:24 CET 2007


Andrew Arrow wrote:
> I've just finished the Joe Armstrong book (coming from a Java and Ruby
> background) and I noticed there was nothing in the book about test
> driven development.
>
> Is the idea that Erlang forces you to write such bug free code there
> are no need for tests?  
Hardly, I certainly can't write bug free code in erlang - languages with 
strict type systems like Haskell might do somewhat better.
Tools like the dialyzer can also be used to enforce type constraints better.

The interavtice erlang shell may to some extent, reduce the incentive to 
write test modules as one can simply try out ones functions in the 
shell, instead of going to the trouble of creating another module.
> Or was this simply beyond the scope of the
> book?
>   
Probably just beyond the scoop of the book.
> Do professional Erlang programmers create lots of unit and functional
> tests like Java and Ruby programmers do?  
It varies.

At my current job at kreditor (www.kreditor.se) we use automated tests 
quite a bit, there was a presentation about our build/test system at the 
last Erlang User Conference (see http://www.erlang.se/euc/07/ "Quality 
Cruising -- Making Java Work for Erlang").

On the other hand, during the time I worked at Ericsson (1998-2002) it 
wasn't until around 2000, that we started to write automated tests for 
the AXD301 (there where lots of manual system and unit tests though) 
e.g. it took several years after the AXDs initial creation before 
automated testing was implemented.

Another common way to deal with bugs especially on production systems, 
is to use lots of logging (there are OTP modules for this) which makes 
it possible to figure out the odd circumstances that resulted in bugs, 
that you forgot about in your test suites.
> If so, is there a way to run
> all the tests like there is with junit/testng or Test::Unit in ruby?
>   
It's pretty trivial to roll your own test framework in erlang, partly 
due to erlangs pattern matching ability, which is very useful to define 
test conditions.

For more advanced tools with fancy GUIs for success/error reporting etc 
there are the:
* OTP test server (used to test erlang)
* yatsy (similar to the OTP test server)
* eunit (version 2 should be the current one - similar to junit/nunit/...)


> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>   



More information about the erlang-questions mailing list