In IntelliJ IDEA 15.0.2 how can I ignore trivial getters and setters (trivial methods) during test coverage measurement?
// should be measure
public void complex() {
fancy();
interesting();
dropDatabase();
}
// should not be measured
public int getNumber() {
return this.number;
}
Measuring every line would result in 75%. Measuring only the above method would result in 100%. And those are 100% of the code useful for testing.
How come I don't find anything about that on the Internet? Am I diving into bad practice?
UPDATE
This code is also eligible for testing:
// should also be tested as it contains logic
public Integer getValidationProgress() {
if (validationProgress == null) {
validationProgress = 0;
}
return validationProgress;
}
Now it is possible, starting with Intellij Idea 2022.3 it is now possible to ignore methods based on annotations.
Settings → Build, Execution, Deployment → Coverage
You can define in settings which annotations should mean that method is ignored. You can create a new annotation or use existing annotations.
More details can be found in blog post IntelliJ IDEA 2022.3 EAP 2: Improved IntelliJ Profiler, Faster IDE Startup, and More