0 votes
1 view
in Devops and Agile by (19.8k points)

I have a requirement to capture the code coverage of my selenium tests to the amount of source code in the server code (web application source code) covered.

For example, the tests for login functionality should capture the amount of code covered in the web application for the login function.

Else need to know which package or class it has touched in web application code for a scenario done. Eg a login

I couldn't find a suitable solution, although I came to know about the Jacoco code coverage tool and tried some samples with the use of the Jacoco Jenkins plugin, there is no success.

I am not aware of the possibility. Please provide me a suggestion on how to achieve this, Thanks in advance.

1 Answer

0 votes
by (63.4k points)

The blanket can work.

This is a JavaScript library.

You annotate the imports in your HTML page with the 'data-cover' attribute:

<script src="sourceScript.js" data-cover></script>

Also blanket replaces your JS files with an annotated copies which report statistics to itself.

The non-trivial step is getting the code-coverage statistics from the blanket, but if I am not mistaken Selenium has an interface that allows you to execute JavaScript functions in the browser engine. The API is here:


Welcome to Intellipaat Community. Get your technical queries answered by top developers !