plugins {
id 'jacoco'
}
jacoco {
toolVersion = "0.8.8"
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir')
}
test {
// finalizedBy : 이(test) 작업에 대해 주어진 종료자 작업을 추가
finalizedBy jacocoTestReport // test 작업이 끝나고 jacocoTestReport를 실행
}
jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHTML')
}
// dependsOn : 이 작업에 지정된 종속성을 추가
dependsOn test // jacocoTestReport 에 test라는 종속성을 추가
finalizedBy 'jacocoTestCoverageVerification'
}
jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true
//코드 버커리지 체크 기준
element = 'CLASS'
limit {
counter = 'METHOD'
value = 'COVEREDRATIO'
minimum = 0.5
}
}
}
}
id 'jacoco'
finalizedBy jacocoTestReport
커버리지 체크 기준이 되는 element는 다음 중에 하나를 선택할 수 있습니다. 위의 샘플처럼 CLASS를 선택하면 클래스 단위로 브랜치와 라인 커버리지를 체크합니다.
BUNDLE (default): 패키지 번들
PACKAGE: 패키지
CLASS: 클래스
SOURCEFILE: 소스파일
METHOD: 메소드
설정 가능한 counter는 아래와 같습니다. (JacocoLimit ‘counter’ 참고)
LINE: 빈 줄을 제외한 실제 코드의 라인 수
BRANCH: 조건문 등의 분기 수
CLASS: 클래스 수
METHOD: 메소드 수
INSTRUCTION (default): Java 바이트코드 명령 수. Java bytecode instruction listings
COMPLEXITY: 복잡도. 자세한 복잡도 계산은 Coverage Counters – JaCoCo docs 참고
그리고 value는 아래 중에서 선택할 수 있습니다. (JacocoLimit ‘value’ 참고)
TOTALCOUNT: 전체 개수
MISSEDCOUNT: 커버되지 않은 개수
COVEREDCOUNT: 커버된 개수
MISSEDRATIO: 커버되지 않은 비율. 0부터 1 사이의 숫자로, 1이 100%입니다.
COVEREDRATIO (default): 커버된 비율. 0부터 1 사이의 숫자로, 1이 100%입니다.
Execution failed for task ':jacocoTestCoverageVerification'.
> Rule violated for class partner42.modulecommon.repository.random.RandomMatchSearch: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.sse.SseRepositoryKeyRule: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.QRole: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.User: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.Authority: methods covered ratio is 0.2, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.User.UserBuilder: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.QUserRole: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.Authority.AuthorityBuilder: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.user.QAuthority: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.slack.SlackBotService: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.slack.SlackBotApi: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.activity.ActivityType: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.activity.ActivityMatchScore: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.QMatchConditionMatch: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.QArticleMatchCondition: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.TypeOfStudy: methods covered ratio is 0.2, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.TimeOfEating: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.QMatchCondition: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.WayOfEating: methods covered ratio is 0.3, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.MatchConditionMatch: methods covered ratio is 0.1, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.matchcondition.MatchConditionMatch.MatchConditionMatchBuilder: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.random.RandomMatch.MatchConditionComparator: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.random.RandomMatchCondition: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.producer.AlarmProducer: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.BaseEntity: methods covered ratio is 0.3, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.BaseTimeEntity: methods covered ratio is 0.3, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.subscriber.RedisMessageSubscriber: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.member.Member.MemberBuilder: methods covered ratio is 0.3, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.kafka.KafkaConsumerConfig: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.kafka.KafkaProducerConfig: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.kafka.AlarmEvent: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.kafka.KafkaTopicConfig: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.redis.LettuceConnectionConfig: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.config.BootstrapDataLoader: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.redis.RedisTransactionUtil.1: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.redis.RedisTransactionUtil.2: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.redis.RedisTransactionUtil: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.article.QArticleMember: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.article.Article.ArticleBuilder: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.opinion.QOpinion: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.utils.RandomUtils: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.NotAuthorException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.InfraException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.NoEntityException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.SlackException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.SseException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.BusinessException: methods covered ratio is 0.3, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.exception.RandomMatchAlreadyExistException: methods covered ratio is 0.0, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.alarm.Alarm.AlarmBuilder: methods covered ratio is 0.4, but expected minimum is 0.5
Rule violated for class partner42.modulecommon.domain.model.alarm.AlarmArgs.AlarmArgsBuilder: methods covered ratio is 0.0, but expected minimum is 0.5