[erlang-questions] Unit testing code - whence?

Bob Ippolito bob@REDACTED
Tue Jul 5 23:34:37 CEST 2011


On Tue, Jul 5, 2011 at 2:27 PM, Alex Arnon <alex.arnon@REDACTED> wrote:
>
> What are the conventions regarding placement of unit test code and
> invocation?
> Considerations:
> I tend to generate a lot of unit tests - 2x..4x SLOC of the tested module's
> code is not uncommon.
> Should the unit test functions be placed in their own module?
> If so - what is the naming convention for the new modue: 'test_mymod' /
> 'mymod_test' or something else?

Yes. The convention is to place them in test/mymod_tests.erl. These
will get picked up by rebar eunit.

> What is the preferred way, if there are many small UT functions: function
> *_test() per UT, or separate into test sets by group, e.g.:
> api_unit_test_(), internal_unit_test_().

I don't think there is as much consensus for this. I do whatever makes
sense at the time. I don't try and group tests together unless it's
easier to write the code that way (e.g. with a list comprehension, or
if they share the setup/teardown in a foreach).

-bob



More information about the erlang-questions mailing list