Getting test results from Eunit in Erlang

后端 未结 3 1669
-上瘾入骨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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 05:01

    No easy or documented way, but there are currently two ways you can do this. One is to give the option 'event_log' when you run the tests:

    eunit:test(my_module, [event_log])
    

    (this is undocumented and was really only meant for debugging). The resulting file "eunit-events.log" is a text file that can be read by Erlang using file:consult(Filename).

    The more powerful way (and not really all that difficult) is to implement a custom event listener and give it as an option to eunit:

    eunit:test(my_module, [{report, my_listener_module}])
    

    This isn't documented yet, but it ought to be. A listener module implements the eunit_listener behaviour (see src/eunit_listener.erl). There are only five callback functions to implement. Look at src/eunit_tty.erl and src/eunit_surefire.erl for examples.

提交回复
热议问题