尝试运行集成测试时遇到一些问题。我刚刚添加了使用logback进行日志记录,并使用Groovy作为配置。它可以构建并正常运行,但是在运行集成时出现以下错误:
15:12:36,813 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
15:12:36,813 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.groovy] at [file:/C:/cdl_install/workspace/bank-details-validation/out/production/resources/logback.groovy]
15:12:36,815 |-ERROR in ch.qos.logback.classic.LoggerContext[default] - Groovy classes are not available on the class path. ABORTING INITIALIZATION.
当我进行干净的构建时,所有测试都通过了OK,但是当我单独运行集成测试时失败了。我猜这是我的build.gradle文件中的依赖项存在问题,但对我来说似乎不错。
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'idea'
id 'eclipse'
id 'jacoco'
id "org.sonarqube" version "2.7.1"
id "org.owasp.dependencycheck" version "5.3.0"
}
group = 'uk.co.cdl.account'
version = '0.0.1-SNAPSHOT'
bootJar {
archiveFileName = "${archiveBaseName.get()}-${archiveVersion.get()}.${archiveExtension.get()}"
}
compileJava{
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
apply from: "$rootDir/gradle/owasp.gradle"
apply from: "$rootDir/gradle/codequality.gradle"
apply from: "$rootDir/gradle/jacoco.gradle"
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'com.google.guava', name: 'guava', version: '28.2-jre'
testCompile('org.junit.jupiter:junit-jupiter-params:5.1.0')
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: '2.17.0'
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
test {
outputs.dir snippetsDir
useJUnitPlatform()
}