如何配置sonar.junit.reportPaths

问题描述 投票:0回答:1

我曾多次尝试在 Gradle 中配置此 sonarqube 属性

sonar.junit.reportPaths
,但仍然收到相同的错误消息。
Gradle 版本 -> 6.7.1
SonarQube 服务器版本 -> 8.9(docker 镜像)
Java版本->openjdk 11.0.2
Intellij 版本 -> 2021.1.2
我的 Sonarqube Gradle 配置如下:

plugins {
    id 'java'
    id 'jacoco'
    id "org.sonarqube" version "3.3"
    id 'org.jetbrains.kotlin.jvm' version '1.5.20'
}

sonarqube {
    properties {
        property 'sonar.projectName', 'Snippets of Java code'
        property 'sonar.junit.reportPaths', 'build/test-results/test'
        property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/test/jacocoTestReport.xml'
        property 'sonar.inclusions', '*.java,*.kt'
    }
}

jacocoTestReport {
    reports {
        xml.required = true
        csv.required = false
    }
}

我仍然收到以下消息:

Resource not found: com.sammy.service.JavaFareTest under the directory /Users/samuelifere/IdeaProjects/codingChallenges while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: com.sammy.model.JavaCardTest under the directory /Users/samuelifere/IdeaProjects/codingChallenges while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly

我读了几个 stackoverflow 页面,例如: 12但仍然没有帮助解决我的问题。任何帮助将不胜感激,以便它可以正确找到资源。

我用来通过 Gradle 运行此命令的命令是:

./gradlew clean build jacocoTestReport sonarqube
gradle sonarqube java-11 gradle-plugin jacoco-plugin
1个回答
0
投票

我发现问题出在我的自定义 AppError 模型上。
这实际上应该是这样的,才能正常工作!
它不喜欢我添加到字段中的“私有”修饰符。

class AppError(var errorCode: Int?,
               var status: String?,
               @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ssZ", timezone = "Europe/London")
               val timestamp: Instant,
               var message: String?)
© www.soinside.com 2019 - 2024. All rights reserved.