Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k 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 (62.9k 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:

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, you should enroll yourself in industry-based Selenium online courses!

Browse Categories