Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Eunit is really simple and fit very well for module test or library test at white box level. It is integrated to rebar.</p> <p>Common Test is more oriented for black box testing and application and system of application test. It comes with test coverage very easily.</p> <p><strong>Edit</strong> (after Andy comment):</p> <p>It is right that you can use Common test for unitary white box test, as well as it is right that you can leverage eunit to some application test using fixtures. </p> <p>However eUnit is very handy for simple unitary test: you write a function myFun, you add a test function myFun_test or a test generator myFun_test_ (useful to test many patterns even is some test fails in the middle) in your test module and that's it. You can run it as often as you want (no history of test).</p> <p>Common test asks you to list each test case in the all function or in a group. As far as I know it has not test generator so it is less easy to go through all test patterns of each function. It is why I think it is less adapted to unitary white box tests. On the other hand, the init_per_testcase, init_per_group ... are much more flexible than eunit fixtures to organize the tests when they need some application context to run. Common Test also keeps an history of all tests done in the log directory, It is nice, but I suggest to limit the number of run to keep it useful.</p> <p><strong>EDIT:</strong></p> <p>To avoid the problem of not exported functions, for both eunit and common test, it is possible to use defines. for example in rebar.config (because I use separate files for eunit tests):</p> <pre><code>{eunit_compile_opts, [{d,'EUNIT_TEST',true}]}. {erl_opts, [debug_info, warn_export_all]}. </code></pre> <p>and in a module, if it is necessary:</p> <pre><code>%% export all functions when used in eunit context -ifdef(EUNIT_TEST). -compile(export_all). -endif. </code></pre> <p>You can verify that it only modify the compiled code for eunit</p> <pre><code>D:\git\helper&gt;rebar clean eunit compile ==&gt; helper (clean) ==&gt; helper (eunit) Compiled test/help_list_tests.erl Compiled test/help_ets_tests.erl Compiled test/help_num_tests.erl Compiled src/help_ets.erl Compiled src/help_list.erl Compiled src/helper.erl src/help_num.erl:6: Warning: export_all flag enabled - all functions will be exported Compiled src/help_num.erl Compiled src/help_code.erl All 31 tests passed. Cover analysis: d:/git/helper/.eunit/index.html ==&gt; helper (compile) Compiled src/help_ets.erl Compiled src/help_list.erl Compiled src/helper.erl Compiled src/help_num.erl Compiled src/help_code.erl </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload