== ==
Cover:A Coverage Analysis Tool for Erlang <br>
Erlang覆盖率分析工具
Level:module|function|clause|line <br>
Analysis:coverage|calls <br>
以下只是最近本的介绍 <br>
1.start/0 <br>
2.compile/0 <br>
3.compile_directory/0 <br>
4.analyse/1 <br>
5.analyse_to_file/2 analyse_to_file(lxw,[html])生成html分析页面 <br>
6.stop/1 <br>
以前我没有做过类似分析,第一次用有点摸不着北。编译后直接输出html了结果发现所有的覆盖率为0(LOL当然了因为程序没有运行过)。
1 -module(covertest). 2 -compile(export_all). 3 test() -> 4 cover:start(), 5 % cover:compile("chat.erl"), 6 cover:compile_directory(), 7 chat:start(2), 8 sleep(), 9 cover:analyse_to_file(chat,[html]). 10 11 sleep() -> 12 receive 13 after 2000 -> 14 true 15 end. ~ ------------------------------------- 1 -module(chat). 2 -compile(export_all). 3 %-behaviour(gen_server). 4 start(N) -> 5 start_link(), 6 test(N), 7 testcast(), 8 test(). 9 rece(N)-> 10 receive 11 after N-> 12 true 13 end. 14 15 test(N)-> 16 gen_server:call(?MODULE, {test,N}). 17 test()-> 18 chat ! {test,1}. 19 testcast() -> 20 gen_server:cast(?MODULE,castttt). 21 22 start_link() -> 23 gen_server:start_link({local,?MODULE},?MODULE,[],[]). 24 25 init([]) -> 26 {ok, {}}. 27 28 handle_cast(Msg,State) -> 29 tttt(), 30 % io:format("cast=~p~n",[Msg]), 31 {noreply,State}. 32 33 handle_call({test,Number},From, State) when is_number(Number) -> 34 Reply = Number+1, 38 Reply = numerror, 39 {reply, Reply,State}. 40 handle_info(Ino,State) -> 41 tttt(), 42 % io:format("info=~p~n",[Ino]), 43 {noreply,State}. 44 tttt() -> 45 ok. 36 37 handle_call(_,From, State) ->