我曾多次尝试在 Gradle 中配置此 sonarqube 属性
sonar.junit.reportPaths
,但仍然收到相同的错误消息。
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 页面,例如: 1,2但仍然没有帮助解决我的问题。任何帮助将不胜感激,以便它可以正确找到资源。
我用来通过 Gradle 运行此命令的命令是:
./gradlew clean build jacocoTestReport sonarqube
我发现问题出在我的自定义 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?)