मुझे जुनीट बृहस्पति (5) के आधार पर परीक्षण वातावरण की कॉन्फ़िगरेशन के साथ कठिन समय हो रहा है। मेरे पास दो अलग-अलग त्रुटियां हैं:परीक्षण पर्यावरण विन्यास: एंड्रॉइड + जुनीट 5 + मॉकिटो + स्पेक + कोटलिन
WARNING: TestEngine with ID 'spek' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name...
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;)V
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:61)...
और कॉन्फ़िगरेशन निम्नानुसार है।
मुख्य build.gradle
:
apply plugin: 'org.junit.platform.gradle.plugin'
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "http://dl.bintray.com/jetbrains/spek" }
}
}
junitPlatform {
filters {
engines {
include 'spek'
}
}
}
मॉड्यूल build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'de.mannodermaus.android-junit5'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
...
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.0.2'
testImplementation 'org.jetbrains.spek:spek-api:1.1.4'
testImplementation 'org.jetbrains.spek:spek-junit-platform-engine:1.1.4'
testImplementation junit5()
// testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0' not needed when using the one above
testImplementation 'org.junit.platform:junit-platform-runner:1.0.0'
testImplementation 'org.mockito:mockito-core:2.8.47'
testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0'
testCompileOnly "de.mannodermaus.gradle.plugins:android-junit5-embedded-runtime:1.0.0"
}
यह विन्यास https://github.com/aurae/android-junit5 के आधार पर किया जाता है। लेकिन मैंने इसके बिना भी कोशिश की।
क्या किसी ने इन पुस्तकालयों के लिए निर्भरताओं की एक कार्यप्रणाली स्थापित करने में कामयाब रहे हैं?
संबंधित। https://github.com/JetBrains/spek/issues/256 – tim