gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

Confusion with coverage numbers #770

Open monikadhok opened 7 years ago

monikadhok commented 7 years ago

I have the following code

var o = {}; o.tmp = function(c){ return { a : "model" b : function(...){ c.add(function(){ .... }); c.add(function(){ .... }); } } } o.tmp();

I understand that in this execution, the function "b" can not be executed. Using istanbul, I am getting following numbers : Statements : 55.56% ( 5/9 ) Branches : 100% ( 0/0 ) Functions : 25% ( 1/4 ) Lines : 55.56% ( 5/9 )

I don't understand how 55% of the function is executed. Most of the code is covered with the function declaration of "b". Also, what does (5/9) means? What are the 9 statements here? Thanks in advance, Monika