Source Code Structurebuild.gradle
plugins {
id 'java'
id 'application'
}
ext {
buildId = System.currentTimeMillis()
codinGameMainClass = "com.codingame.App"
}
group = 'com.coding-game-problem'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '8'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
}
test {
reports {
junitXml.enabled = true
def destinationDirectory = System.getProperty("user.home") + "/.gradle/daemon/${buildId}/test-results"
junitXml.destination = file(destinationDirectory)
html.enabled = true
}
useJUnitPlatform {
}
testLogging.events ("STANDARD_ERROR")
testLogging.events ("STANDARD_OUT")
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTEST RESULT: ${result.resultType}"
println "TEST SUMMARY: RAN ${result.testCount} TESTS, " +
"${result.successfulTestCount} SUCCEEDED, " +
"${result.failedTestCount} FAILED, " +
"${result.skippedTestCount} SKIPPED"
}
}
}
tasks.named('test') {
useJUnitPlatform()
}
在我的Test Class中,以下代码行无法导入Mockito库,由于依赖关系未解决而导致编译时错误:
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@DisplayName("ContestServiceTest")
@ExtendWith(MockitoExtension.class)
执行./gradlew构建后,在测试类中出现编译时间问题。请帮忙在这…
1条答案
按热度按时间zi8p0yeb1#
mockito-junit-jupiter只是mockito的扩展名。您需要添加mockito-core本身: