You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please understand that
ISSUES WITHOUT FOLLOWING INFORMATION WILL BE CLOSED WITHOUT COMMENTS!
Thank you for filling feature request!
Scenario
JaCoCo version: 0.8.11
Operating system: Ubuntu Linux
Tool integration: Maven / Ant / CLI / API (for others please report to respective project)
Description of your use case: (detailed description or executable reproducer, e.g. GitHub repo)
Current Behaviour
In some rare cases, some functions/classes cannot be tested. In such cases, the developer has two choices: a) to reduce the coverage ratio, and b) to indicate the function/class as generated. Both choices have their problems: The first one allows for actual functionality to go untested, while the second is misinforming.
Example:
In the following AWS Lambda handler, the default constructor cannot be tested offline because it will attempt a connection with the online source (AWS).
public class InitFunction implements RequestStreamHandler {
private final CodePipelineClient client;
public InitFunction() {
this(defaultCodePipelineClient());
}
public InitFunction(CodePipelineClient client) {
this.client = client;
}
@Override
public void handleRequest(InputStream input, OutputStream output, Context context)
throws IOException {
var event = JsonConfig.JSON.readValue(input, CodePipelineEvent.class);
var request =
PutJobSuccessResultRequest.builder()
.jobId(event.getJob().getJobId()).build();
client.putJobSuccessResult(request);
}
private static CodePipelineClient defaultCodePipelineClient() {
return CodePipelineClient.create();
}
}
Currently, assuming that the requirement for method and class coverage is 100%, Jacoco will complain that the default constructor is not covered. Unfortunately, the default constructor cannot be tested offline because the client attempts to create an internet connection to AWS,
Wanted Behaviour
The desired behavior, is to be able to manually indicate which functions we cannot cover, (either for working on covering them later, or for showing to other developers that this function is not covered). Based on the above example, we would write
to indicate that the function should be ignored.
public class InitFunction implements RequestStreamHandler {
private final CodePipelineClient client;
@JacocoIgnored
public InitFunction() {
this(defaultCodePipelineClient());
}
public InitFunction(CodePipelineClient client) {
this.client = client;
}
@Override
public void handleRequest(InputStream input, OutputStream output, Context context)
throws IOException {
var event = JsonConfig.JSON.readValue(input, CodePipelineEvent.class);
var request =
PutJobSuccessResultRequest.builder()
.jobId(event.getJob().getJobId()).build();
client.putJobSuccessResult(request);
}
@JacocoIgnored
private static CodePipelineClient defaultCodePipelineClient() {
return CodePipelineClient.create();
}
}
Possible Workarounds
One can define an @JacocoGenerated annotation and include it in their code.
The text was updated successfully, but these errors were encountered:
THIS IS A BUG TRACKER ONLY. FOR QUESTIONS PLEASE CHECK FAQ OR USE FORUM:
http://www.jacoco.org/jacoco/trunk/doc/faq.html
https://groups.google.com/forum/?fromgroups=#!forum/jacoco
Please understand that
ISSUES WITHOUT FOLLOWING INFORMATION WILL BE CLOSED WITHOUT COMMENTS!
Thank you for filling feature request!
Scenario
Current Behaviour
In some rare cases, some functions/classes cannot be tested. In such cases, the developer has two choices: a) to reduce the coverage ratio, and b) to indicate the function/class as generated. Both choices have their problems: The first one allows for actual functionality to go untested, while the second is misinforming.
Example:
In the following AWS Lambda handler, the default constructor cannot be tested offline because it will attempt a connection with the online source (AWS).
Currently, assuming that the requirement for method and class coverage is 100%, Jacoco will complain that the default constructor is not covered. Unfortunately, the default constructor cannot be tested offline because the client attempts to create an internet connection to AWS,
Wanted Behaviour
The desired behavior, is to be able to manually indicate which functions we cannot cover, (either for working on covering them later, or for showing to other developers that this function is not covered). Based on the above example, we would write
to indicate that the function should be ignored.
Possible Workarounds
One can define an
@JacocoGenerated
annotation and include it in their code.The text was updated successfully, but these errors were encountered: