tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

Add coverage of object / variable assignment #236

Closed tyge68 closed 8 years ago

tyge68 commented 8 years ago

Currently JSCover (1.0.24) doesn't detect execution of object field value assignment as well as var on multiple lines.

Example:

var a=val1,
      b=val2,
      c=va3; // etc...

or

return {
      fieldA: val1,
      fieldB: val2,
      ....
}

var o = {
    fieldA: val1,
    fieldB: val2
}

Thus the coverage result is wrong and doesn't reflect actual reality of the code execution. Coverage will appear to be less.

tntim96 commented 8 years ago

JSCover line coverage instruments physical lines of code rather than logical JavaScript statements; it works best with code that has exactly one statement per line. If you put multiple statements on a line, or split a line across two or more statements, you may get strange results.

http://tntim96.github.io/JSCover/manual/manual.xml#caveats

tyge68 commented 8 years ago

Thanks, I will fix the code then myself, as JSCover is a nice tool which we could integrate easily as it is Java based, but we use it with Sonar, and many lines are missed then in the report due to above.