[erlang-questions] eunit failure - "*** test module not found ***"

French, Mike Mike.French@REDACTED
Wed Mar 17 12:40:55 CET 2010



> -----Original Message-----
> From: erlang-questions@REDACTED 
> [mailto:erlang-questions@REDACTED]On
> Behalf Of Graeme Defty
> Sent: 17 March 2010 07:43
> To: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] eunit failure - "*** test module not found
***"
> 
> Brilliant!
> 
> ...and almost exactly right, except that 'true' is not 
> the result of a macro but literally the last line of code.

The result and the last line are very often the same.

The result of the test-generating function will be the evaluation of 
the basic unprefixed macro, say 'ok' or 'true', which is handled like this:

  http://www.erlang.org/doc/apps/eunit/chapter.html#Primitives

which says that a single atom is interpreted as a module name,
and presumably EUnit will try to look-up test functions for that module:

  http://www.erlang.org/doc/reference_manual/modules.html#id2270797

and it's the call to true:module_info() that fails with bad module 'true'.

Mike


> On 17 March 2010 00:39, French, Mike 
> <Mike.French@REDACTED> wrote:
> >
> > Graeme,
> >
> > I think this occurs when you omit a leading underscore
> > on an eunit macro in a test-generating function.
> >
> > For example, say you write a simple test function using a basic macro:
> >
> >  basic_test() -> ?assert( 1 + 1 =:= 2 ).
> >
> > Then you decide to convert it to a test-generating function, you should
> > append  an '_' to the function name, and
> > prepend an '_' to the macro    name:
> >
> >  fancy_test_() -> ?_assert( 1 + 1 =:= 2 ).
> >
> > but if you forget to change the macro name:
> >
> >  bad_test_() -> ?assert( 1 + 1 =:= 2 ).
> >
> > then you get the error as you describe:
> >
> >  undefined
> >  *** test module not found ***
> >  ::ok
> >  =======================================================
> >    Failed: 0.  Skipped: 0.  Passed: 0.
> >  One or more tests were cancelled.
> >  error
> >
> > The 'ok' value in the error message is the result of
> > evaluating the function returned by the macro,
> > so your mistake is on a macro that returns 'true'.
> >
> > Mike

Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail
is confidential. It may also be legally privileged. It is intended only for
the stated addressee(s) and access to it by any other person is
unauthorised. If you are not an addressee, you must not disclose, copy,
circulate or in any other way use or rely on the information contained in
this e-mail. Such unauthorised use may be unlawful. We may monitor all
e-mail communications through our networks. If you have received this e-mail
in error, please inform us immediately on sender's telephone number above
and delete it and all copies from your system. We accept no responsibility
for changes to any e-mail which occur after it has been sent.  Attachments
to this e-mail may contain software viruses which could damage your system.
We therefore recommend you virus-check all attachments before opening.
Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business
Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No.
868273


More information about the erlang-questions mailing list