Reputation: 10751
Is there an ability to generate code coverage reports for a JAR file belonging to my class path?
The jar
is already compiled and added as a library to Gradle project.
The test code for jar
is stored in the project.
Upvotes: 4
Views: 3057
Reputation: 1976
Is there an ability to generate code coverage reports for added to classpath jar?
There should be. You are not telling which code coverage tool you are using though. From the tags in the question it appears you are using JaCoCo.
Code coverage typically goes through 3 phases:
In your scenario, what you could do is to unzip the JAR for which you want to have code coverage, instrument the classes within and zip these classes to another JAR. Replace the original JAR with the JAR with instrumented classes.
This is a non standard workflow and may not be easily configured in Ant/Maven, but you can do it programmatically, see the API and API examples
Upvotes: 5
Reputation: 140457
I think you can tailor yourself a solution like this:
Given your comment: it seems that you don't understand what "coverage" is doing for you. The point is: you start a JVM; that JVM runs some code. And while doing so, data is collected about which classes/methods are used, paths taken, etc.
In other words:
Nothing in that process relates to specific JARs. Coverage just checks which code is running. That mapping to "where that code is coming from is a different aspect.
Upvotes: 1