Skip to content

Latest commit

 

History

History
65 lines (39 loc) · 3.04 KB

Code_Coverage_20737a4.md

File metadata and controls

65 lines (39 loc) · 3.04 KB
loio
20737a4c64f448d2af9b9745fbe5d762

Code Coverage

It can be handy to calculate the code coverage of your integration tests, for example, to figure out whether you forgot to test something or to provide statistics on your test quality.

At test execution time, Gherkin offers the option Enable coverage at the top left of the test results. Enabling the option reruns the tests and then lists the files that were tested at the bottom of the page.

Gherkin calculates code coverage for any JavaScript file that is loaded after the test harness. This may cause some system libraries to appear in the results. You can specify which files to calculate code coverage for by adding code to your HTML bootstrap file (after loading OpenUI5, but before running your tests), as follows.


Code coverage with Istanbul relies on a UI5 server and UI5 Middleware Code Coverage.

If you use UI5 Tooling's ui5 serve, you would need to enable it in ui5.yaml and package.json of your project.

<script
  src="path/to/resources/sap/ui/qunit/qunit-coverage-istanbul.js"
  data-sap-ui-cover-only="GherkinWithOPA5/"
  data-sap-ui-cover-never="sap/ui/">
</script>

For more information, see the documentation.


Blanket.js offers code coverage and instrumentation for JavaScript up to ECMAScript Language Specification 5. As of OpenUI5 version 1.113.0, code coverage measurement via Istanbul is the recommended option.

<script
  src="../../resources/sap/ui/qunit/qunit-coverage.js"
  data-sap-ui-cover-only="GherkinWithOPA5/"
  data-sap-ui-cover-never="sap/ui/">
</script>

For more information, see the documentation for Blanket.js on GitHub. Keep in mind that the attribute name is slightly different in the OpenUI5 implementation (data-sap-ui-cover-only instead of data-cover-only).

Related Information

Blanket.js Documentation on GitHub

UI5 Middleware Code Coverage repo on GitHub

Code Coverage Measurement