[erlang-questions] Unit testing code - whence?

Jon Watte jwatte@REDACTED
Wed Jul 6 07:33:34 CEST 2011

Unit tests in a different module means you have to open your module up a lot
more than if the tests are in the same module.

Generally, I write the code, then I include_lib eunit.hrl, then I write the
unit tests. That can all be wrapped in conditional compilation if you need
to. However, when just developing new functions, I typically put the tests
right by the functions they're testing, and only when I'm done do I move
them to the end of the file.

Works for me/us! Your mileage may vary.



Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.

On Tue, Jul 5, 2011 at 2:27 PM, Alex Arnon <alex.arnon@REDACTED> wrote:

> Hi List,
> 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?
> 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_().
> Cheers,
> Alex.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110705/019dbc78/attachment.htm>

More information about the erlang-questions mailing list