小编ale*_*mro的帖子

运行 Junit 5 Android 测试时未解析的引用 jupiter 和 assertTrue

我正在尝试在 Kotlin 中创建一个 Android 测试类来处理,Bitmap但由于这些错误,我无法运行测试。它们仅发生在androidTest中的任何测试类中,但测试中的简单 JVM 测试运行没有问题。

首先,这就是我的测试类的样子

import android.graphics.Bitmap
import androidx.test.core.app.ApplicationProvider
import org.junit.jupiter.api.Assertions.assertTrue

class RoundImageTest {

    @org.junit.jupiter.api.Test
    fun imagesRatio() {
        // test with square images
        val squareBitmap: Bitmap = Bitmap.createBitmap(
             164, 164, Bitmap.Config.ARGB_8888
        )
        assertTrue(squareBitmap.height == squareBitmap.width)
    }
}
Run Code Online (Sandbox Code Playgroud)

按照此处指定的说明,我将其放入项目的build.gradle中

dependencies {
    classpath 'com.android.tools.build:gradle:4.0.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'eu.appcom.gradle:android-versioning:1.0.2'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.10.0"
    classpath "org.jlleitschuh.gradle:ktlint-gradle:9.2.1"
    classpath("de.mannodermaus.gradle.plugins:android-junit5:1.6.2.0")
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-instrumentation junit5

2
推荐指数
1
解决办法
4525
查看次数

标签 统计

android ×1

android-instrumentation ×1

junit5 ×1

kotlin ×1