JavaScript代码覆盖率工具:istanbul

jopen 10年前

istanbul 是一个采用 JavaScript 开发代码覆盖率检查工具。它具有以下特性:

  • All-javascript instrumentation library that tracks statement, branch, and function coverage and reverse-engineers line coverage with 100% fidelity.
  • Module loader hooks to instrument code on the fly
  • Command line tools to run node unit tests "with coverage turned on" and no cooperation whatsoever from the test runner
  • HTML and LCOV reporting.
  • Ability to use as middleware when serving JS files that need to be tested on the browser.
  • Can be used on the command line as well as a library
  • Based on the awesome esprima parser and the equally awesome escodegen code generator
  • Well-tested on node 0.4.x, 0.6.x, 0.8.x and the browser (instrumentation library only)

用例

支持以下用例
  • transparent coverage of nodejs unit tests
  • ability to use in an npm test script for conditional coverage
  • instrumentation of files in batch mode for browser tests (using yeti for example)
  • Server side code coverage for nodejs by embedding it as custom middleware

示例报表:

http://gotwarlost.github.io/istanbul/public/coverage/lcov-report/index.html

JavaScript代码覆盖率工具:istanbul

项目主页:http://www.open-open.com/lib/view/home/1411615610703