我有一个Android Multi-Module项目,并想添加JUnit测试。有趣的是,在添加第一个Testclass之后,当我想要开始测试时,Gradle构建失败。错误消息对我来说并不明确,因为它们没有任何意义。
Gradle模块依赖于具有默认依赖项的基本模块。
apply plugin: 'kotlin'
dependencies {
api "org.koin:koin-android:1.0.2"
api "com.jakewharton.threetenabp:threetenabp:1.1.1"
api "org.jetbrains.kotlin:kotlin-stdlib:1.3.11"
}
apply plugin: 'kotlin'
dependencies {
testApi "org.koin:koin-test:1.0.2"
testApi "org.amshove.kluent:kluent-android:1.42"
testApi "junit:junit:4.12"
}
apply plugin: 'kotlin'
dependencies {
implementation "com.squareup.retrofit2:retrofit:2.1.0"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0"
implementation "org.jsoup:jsoup:1.11.3"
implementation "com.squareup.retrofit2:converter-scalars:2.1.0"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.11"
api project(":core-libs")
testApi project(":core-test-libs")
}
class RegionListJsoupParserTest : KoinTest {
private val underTest = RegionListJsoupParser()
@Test
fun parseRegionResult() {
val testFile = File("Ligen - Turnier.de.html")
val testDocument = Jsoup.parse(testFile, StandardCharsets.UTF_8.name())
val result = underTest.parse(testDocument)
println(result)
}
}
仅通过Android Studio构建项目即可正常运行。但是,当我想运行测试方法时,compileKotlin失败,并出现了许多错误:
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (4, 12): Unresolved reference: threeten
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (5, 12): Unresolved reference: threeten
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (7, 10): Class 'QueryDateTimeFormatter' is not abstract and does not implement abstract member public abstract fun format(dateTime: LocalDateTime): String defined in de.tim_brueggenthies.android.baselibraries.LocalDateTimeFormatter
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (9, 28): Unresolved reference: DateTimeFormatter
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (9, 48): Unresolved reference: DateTimeFormatter
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (11, 5): 'format' overrides nothing
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\QueryDateTimeFormatter.kt: (11, 35): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (4, 12): Unresolved reference: threeten
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (8, 74): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (8, 117): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (20, 31): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (20, 47): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (22, 30): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClient.kt: (22, 46): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClientImpl.kt: (5, 12): Unresolved reference: threeten
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClientImpl.kt: (17, 74): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClientImpl.kt: (17, 98): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\TurnierClientImpl.kt: (40, 17): Unresolved reference: LocalDateTime
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (5, 12): Unresolved reference: koin
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (7, 33): Unresolved reference: module
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (8, 5): Unresolved reference: single
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (8, 32): Unresolved reference: get
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (8, 39): Unresolved reference: get
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (8, 46): Unresolved reference: get
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (9, 5): Unresolved reference: single
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (10, 5): Unresolved reference: single
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (10, 37): Unresolved reference: get
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (10, 44): Unresolved reference: get
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (11, 5): Unresolved reference: single
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (12, 5): Unresolved reference: single
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\KoinModules.kt: (13, 5): Unresolved reference: factory
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\TurnierApiDi.kt: (3, 12): Unresolved reference: koin
e: E:\Remote Repos\tura-badminton-android-app\turnierapiclient\src\main\java\de\tim_brueggenthies\android\turnierapiclient\di\TurnierApiDi.kt: (8, 9): Unresolved reference: loadKoinModules
所有“未解析的引用”均无效,并且未覆盖的方法也将被覆盖。
如果有人知道为什么会出现此问题,那将很好。