Whence eunit:test/0?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Whence eunit:test/0?

Roger Lipscombe-2
1> eunit:test().
  All 6 tests passed.
ok

But there's no `test/0` function *in* eunit.erl. What's going on?
Reply | Threaded
Open this post in threaded view
|

Re: Whence eunit:test/0?

Brujo Benavides-3
It’s the magic of parse transforms!


When you include that header file, it will create a test/0 function for you.

On 15 Nov 2019, at 17:24, Roger Lipscombe <[hidden email]> wrote:

1> eunit:test().
 All 6 tests passed.
ok

But there's no `test/0` function *in* eunit.erl. What's going on?

Reply | Threaded
Open this post in threaded view
|

Re: Whence eunit:test/0?

Roger Lipscombe-2
Ah. Specifically this:
https://github.com/erlang/otp/blob/master/lib/eunit/src/eunit_autoexport.erl#L89

Module:test() -> eunit:test(Module).

...which invokes the test cases in Module *and* Module_tests. In the
case of eunit_tests, there are 6 tests.

It's been a long day.

On Fri, 15 Nov 2019 at 20:29, Brujo Benavides <[hidden email]> wrote:

>
> It’s the magic of parse transforms!
>
> eunit.erl includes eunit.hrl: https://github.com/erlang/otp/blob/8e4abc44d58e61753716e63b23c6b44d221feb15/lib/eunit/src/eunit.erl#L30
>
> When you include that header file, it will create a test/0 function for you.
> Check it out: http://erlang.org/doc/apps/eunit/chapter.html#running-eunit
>
> ________________________________
> Brujo Benavides
>
>
>
> On 15 Nov 2019, at 17:24, Roger Lipscombe <[hidden email]> wrote:
>
> 1> eunit:test().
>  All 6 tests passed.
> ok
>
> But there's no `test/0` function *in* eunit.erl. What's going on?
>
>