迁移到 junit5 后无法 运行 测试
Unable to run tests after migrating to junit5
我正在 运行 使用 gradle 在 android 上进行测试,我们正在将我们的框架迁移到 junit5 以利用它的一些标记和过滤功能。我已经在我的 build.gradle 文件中创建了依赖项,我可以使用 android studio 中的装订线图标来构建和 运行,但我无法 运行 我从命令行进行的测试。我收到以下错误。
* What went wrong:
Execution failed for task ':app:compileTestKotlin'.
> Could not resolve all files for configuration ':app:testCompileClasspath'.
> Could not find junit:junit:5.7.0.
Searched in the following locations:
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.pom
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.jar
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.pom
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.jar
Required by:
project :app
这是我的 build.gradle 在应用级别
plugins {
id 'io.qameta.allure' version '2.8.1' // Latest Plugin Version
id 'java'
}
allure {
autoconfigure = true
version = '2.13.7' // Latest Allure Version
useJUnit5 {
version = '2.13.7' // Latest Allure Version
}
}
sourceCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
dependencies {
testImplementation(
'org.junit.jupiter:junit-jupiter-params:5.7.0',
'org.junit.jupiter:junit-jupiter-api:5.7.0'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
)
}
test {
useJUnitPlatform(){
includeEngines 'junit-jupiter'
}
}
apply plugin: 'kotlin'
test {
systemProperty 'platform', project.findProperty('platform')
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation "io.appium:java-client:7.2.0"
// implementation 'junit:junit:4.12'
implementation 'junit:junit:5.7.0'
}
这里是项目级别的 build.gradle。
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
错误消息说了。 implementation 'junit:junit:5.7.0'
是一个不存在的依赖项。离开它,它可能已经工作了。
我正在 运行 使用 gradle 在 android 上进行测试,我们正在将我们的框架迁移到 junit5 以利用它的一些标记和过滤功能。我已经在我的 build.gradle 文件中创建了依赖项,我可以使用 android studio 中的装订线图标来构建和 运行,但我无法 运行 我从命令行进行的测试。我收到以下错误。
* What went wrong:
Execution failed for task ':app:compileTestKotlin'.
> Could not resolve all files for configuration ':app:testCompileClasspath'.
> Could not find junit:junit:5.7.0.
Searched in the following locations:
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.pom
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.jar
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.pom
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.jar
Required by:
project :app
这是我的 build.gradle 在应用级别
plugins {
id 'io.qameta.allure' version '2.8.1' // Latest Plugin Version
id 'java'
}
allure {
autoconfigure = true
version = '2.13.7' // Latest Allure Version
useJUnit5 {
version = '2.13.7' // Latest Allure Version
}
}
sourceCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
dependencies {
testImplementation(
'org.junit.jupiter:junit-jupiter-params:5.7.0',
'org.junit.jupiter:junit-jupiter-api:5.7.0'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
)
}
test {
useJUnitPlatform(){
includeEngines 'junit-jupiter'
}
}
apply plugin: 'kotlin'
test {
systemProperty 'platform', project.findProperty('platform')
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation "io.appium:java-client:7.2.0"
// implementation 'junit:junit:4.12'
implementation 'junit:junit:5.7.0'
}
这里是项目级别的 build.gradle。
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
错误消息说了。 implementation 'junit:junit:5.7.0'
是一个不存在的依赖项。离开它,它可能已经工作了。