我有一个带有 4 个测试和以下 build.gradle 的 Spring Gradle 项目:
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
version = '0.0.1'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
//Rest Controller
compile 'org.springframework.boot:spring-boot-starter-web'
//Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
//Tests
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testCompile 'com.h2database:h2'
//Database
compile("mysql:mysql-connector-java")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
//Authentication
compile 'org.springframework.security:spring-security-crypto' //e.g. PasswordEncoder
compile 'org.springframework.boot:spring-boot-starter-security' //e.g. @PreAuthorize
//ResourceAssembler
compile 'org.springframework.boot:spring-boot-starter-hateoas'
//JWT Token generation
compile("com.auth0:java-jwt:3.4.0")
}
我可以用“运行测试”开始每个测试,它工作得很好,但是当我尝试“运行所有测试”时,它失败并显示消息“运行“全部”时出错:没有 junit.jar”
我已经尝试添加以下任何依赖项,但都没有解决问题:
testCompile 'junit:junit:4.12
testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')
我正在使用 IntelliJ
冉冉说
相关分类