erlang单元测试

阅读更多

 

  • Including the EUnit header file

    -include("eunit/include/eunit.hrl").

    test/0, xxx_test(), xxx_test_()

  • Writing simple test functions

    Use exceptions to signal failures

    Using assert macros

  • Running EUnit

    eunit:test(Module) <==> Module:test()

    Putting tests in seperate modules: m_tests, only eunit:test(Module)

    Eunit captures the output: use ?debugMsg(Text), ?debugFmt(FmtStr, Value)

  • Writing test generating functions

    ?_assert() vs. ?assert()

  • An example

  • Disabling testing

    erlc -DNOTEST Module.erl

  • Avoiding compile-time dependency on EUnit

    -ifdef(TEST).

    -include_lib("eunit/include/eunit.hrl").

    -endif.

 

 

你可能感兴趣的:(erlang单元测试)