4

How can i generate an javascript test coverage using jstestdriver?

I am able to run the javascript test using jstestdriver. I want to generate a coverage report to check how much percentage of javascript files i have tested.

I have read through this website http://code.google.com/p/js-test-driver/wiki/CodeCoverage and followed the instructions provided. However, i still can not get a coverage report.

My folder struture right now is and the relevant files i have imported for coverage report:

-trunk
  -app
  -test
    -lib
      -jstestdriver
        -javascipt (includes coverage.js, CoverageTest.js, Instrumentable.js, plugin.js)
        -plugins (includes coverage.jar)
    -unit
      -controllerSpecs.js
  -config
    -coverage.conf
  -scripts
    - test-server.sh
    - test.sh
    - web-server.js

In my coverage.conf, I have the following content:

server: http://localhost:9876

load:
  - test/lib/jstestdriver/javascript/coverage.js
  - test/lib/jstestdriver/javascript/CoverageTest.js
  - test/unit/*.js
plugin:
  - name: "coverage"
    jar: "test/lib/jstestdriver/plugins/coverage.jar"
    module: "com.google.jstestdriver.coverage.CoverageModule"

exclude:

Thank you in advance for your help=)

Edgar Villegas Alvarado
  • 18,204
  • 2
  • 42
  • 61
Jia-Luo
  • 3,023
  • 5
  • 16
  • 17

1 Answers1

2

It didn't work as expected for me either, but now it does. I'm not sure why but I think all I changed was the whitespace in the config file:

plugin:
- name: "coverage"
jar: "coverage-1.3.4.b.jar"
module: "com.google.jstestdriver.coverage.CoverageModule"

Note: the .dat file which was generated was empty the first time I ran this.

(I have the CodeCoverage jar in the same directory as the .conf file)

Adam Lynch
  • 3,341
  • 5
  • 36
  • 66