September 2013
Intermediate to advanced
548 pages
12h 25m
English
When we’re testing our code, it’s often nice to see not only which lines of code are executed a lot but also which lines are never executed. Lines of code that are never executed are a potential source of error, so it’s really good to find out where these are. To do this, we use the program coverage analyzer.
Here’s an example:
| | 1> cover:start(). %% start the coverage analyser |
| | {ok,<0.34.0>} |
| | 2> cover:compile(shout). %% compile shout.erl for coverage |
| | {ok,shout} |
| | 3> shout:start(). %% run the program |
| | <0.41.0> |
| | Playing:<<"title: track018 performer: .. ">> |
| | 4> %% let the program run for a bit |
| | 4> cover:analyse_to_file(shout). %% analyse the results |
| | {ok,"shout.COVER.out"} %% this is the results file |
The results ...
Read now
Unlock full access