Getting test results from Eunit in Erlang

后端 未结 3 1670
-上瘾入骨i
-上瘾入骨i 2021-01-06 04:32

I am working with Erlang and EUnit to do unit tests, and I would like to write a test runner to automate the running of my unit tests. The problem is that eunit:test/1 seems

3条回答
  •  长发绾君心
    2021-01-06 04:58

    If you are using rebar you don't have to implement your own runner. You can simply run:

    rebar eunit
    

    Rebar will compile and run all tests in the test directory (as well as eunit tests inside your modules). Furthermore, rebar allows you set the same options in the rebar.config as in the shell:

    {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
    

    You can use these options also in the shell:

    > eunit:test([foo], [verbose, {report,{eunit_surefire,[{dir,"."}]}}]).
    

    See also documentation for verbose option and structured report.

    An alternative option would be to use Common Test instead of Eunit. Common Test comes with a runner (ct_run command) and gives you more flexibility in your test setup but is also a little more complex to use. Common Test lacks on the available macros but produces very comprehensible html reports.

提交回复
热议问题