https://www.baeldung.com/jacoco-report-exclude аннотацию, чтобы исключить класс из покрытия jacoco.Я обнаружил, что jacoco ищет сгенерированное слово в аннотации и исключает класс аннотации.
https://github.com/jacoco/jacoco/pull/822/files
Итак, пошли дальше и создали следующую аннотацию: -
Код: Выделить всё
@Target({ElementType.TYPE,ElementType.METHOD})
public @interface ExcludeFromJacocoGeneratedReport {
}
Код: Выделить всё
@ExcludeFromJacocoGeneratedReport
class UserRepoImpl {
public long getCountById(long userId){
UserFetcher fether =
// this shows up as red in jacoco report coverage, ideally it shouldn't as i have already excluded the whole class using ExcludeFromJacocoGeneratedReport annotation.
new UserFetcher public void init(long userId){
//initialise user
}
};
}
public void updateUser(User user){
//update the user
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... g-anonymou