未解析的引用:junit
我正在使用Kotlin和LibGDX框架编写游戏。我是测试新手。我已经通过了一些关于如何创建简单测试的基本教程。以及如何配置渐变。我刚刚点击类并选择创建测试。
但是,当我尝试构建项目时,我得到一个错误:
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (1, 12): Unresolved reference: junit
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (2, 12): Unresolved reference: junit
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (6, 6): Unresolved reference: Test
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (8, 9): Unresolved reference: Assertions
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (11, 6): Unresolved reference: Test
e: /Users/maximternovtsi/bagel/core/src/test/test/BagelTest.kt: (13, 9): Unresolved reference: Assertions
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileKotlin'.
BagelTest看起来像这样:
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.BeforeEach
internal class BagelTest {
@BeforeEach
internal fun setUp() {
}
@Test
internal fun passes() {
assert(true)
}
}
我猜gradle没有看到junit,但我遵循了所有说明。也许我错过了一些东西。
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'org.multi-os-engine:moe-gradle:1.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.51"
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "Bagel"
gdxVersion = '1.9.8'
junitJupiterVersion = '5.0.2'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "kotlin"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
apply plugin: "kotlin-android"
configurations { natives }
dependencies {
compile project(":core")
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.51"
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
apply plugin: "kotlin"
/*kotlin {
experimental {
coroutines 'enable'
}
}*/
sourceSets.test.java.srcDirs = ["/test"]
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.51"
compile "com.badlogicgames.ashley:ashley:1.7.3"
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
// testCompile "org.mockito:mockito-core:2.2.7"
}
}
tasks.eclipse.doLast {
delete ".project"
}