Code coverage data

nzakas edited this page Nov 23, 2011 · 1 revision

If you've instrumented the JavaScript to test using YUI Test Coverage, then you can retrieve the coverage information by using the YUITest.TestRunner.getCoverage() method. By default, this method returns an object representing the coverage data of the tests that were just run (the method returns null if called while tests are still running). You can optionally specify a format in which the results should be returned. There are four possible formats:

  • YUITest.CoverageFormat.JSON - JSON
  • YUITest.CoverageFormat.XdebugJSON - JSON formatted Xdebug

You can pass any of these into YUITest.TestRunner.getCoverage() to get a string with the test result information properly formatted. As mentioned earlier, you need to ensure that YUITest.Util.JSON is pointing to a valid JSON object.