Trying to setup spek, but get the following error:
Error:(157, 0) Could not find method testRuntime() for arguments [org.jetbrains.spek:spek-junit-platform-engine:1.0.89] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I'm using:
What's missing?
testRuntime is only available if you apply gradle's standard java plugin. By any chance are you using the android plugin? If so, testCompile should suffice.
I had the same problem on Android and changed it testCompile. Now I have this weird error message:
Error:Could not find property 'test' on SourceSet container.
Any tip?
Would love to use this on my project.
@fabiocarballo can you paste your build file?
sure!:
I've pasted the wrong error message above. It is this one:
Error:Task with name 'testClasses' not found in project ':app'.
The build of app.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath libDependencies.kotlinAndroidExtensions
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2'
}
}
apply plugin: 'org.junit.platform.gradle.plugin'
junitPlatform {
engines {
include 'spek'
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.hole19golf.wear"
minSdkVersion 'N'
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-libs/google-play-services.pro'
proguardFile 'proguard-libs/gson.pro'
proguardFile 'proguard-libs/kotlin.pro'
proguardFile 'proguard-libs/square-picasso.pro'
proguardFile 'proguard-libs/support-lib.pro'
proguardFile 'proguard-libs/rx.pro'
proguardFile 'proguard-libs/okhttp.pro'
proguardFile 'proguard-libs/retrofit.pro'
proguardFile 'proguard-libs/parceler.pro'
testProguardFile 'test.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-libs/google-play-services.pro'
proguardFile 'proguard-libs/gson.pro'
proguardFile 'proguard-libs/kotlin.pro'
proguardFile 'proguard-libs/realm.pro'
proguardFile 'proguard-libs/square-picasso.pro'
proguardFile 'proguard-libs/support-lib.pro'
proguardFile 'proguard-libs/rx.pro'
proguardFile 'proguard-libs/okhttp.pro'
proguardFile 'proguard-libs/retrofit.pro'
proguardFile 'proguard-libs/parceler.pro'
testProguardFile 'test.pro'
}
}
productFlavors {
internal {
applicationId "com.hole19golf.wear"
}
production {
applicationId "com.hole19golf.wear"
}
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Support Dependencies
compile supportDependencies.wearSupportLibrary
compile supportDependencies.v13SupportLibrary
// Play Services Dependencies
compile playServicesDependencies.wearPlayServices
compile playServicesDependencies.location
// Firebase Dependencies
compile firebaseDependencies.messaging
// Kotlin Dependencies
compile libDependencies.kotlinStdLib
compile libDependencies.anko
// Core Dependencies
compile libDependencies.okHttp
compile libDependencies.robotoTextView
compile libDependencies.gson
compile libDependencies.picasso
// Reactive Dependencies
compile reactiveDependencies.rxJava
compile reactiveDependencies.rxAndroid
//Retrofit Dependencies
compile retrofitDependencies.retrofit
compile retrofitDependencies.adapterRxJava
compile retrofitDependencies.gsonConverter
compile retrofitDependencies.logging
// Test Dependencies
testCompile testDependencies.androidTestRules
testCompile testDependencies.androidTestRunner
testCompile testDependencies.kotlinJunit
testCompile 'junit:junit:4.12'
testCompile 'com.squareup.assertj:assertj-android:1.0.0'
testCompile('org.mockito:mockito-core:2.0.42-beta')
testCompile 'org.json:json:20140107'
testCompile "com.nhaarman:mockito-kotlin:0.5.0"
testCompile 'org.skyscreamer:jsonassert:1.3.0'
testCompile 'org.jetbrains.spek:spek-api:1.0.89'
testCompile'org.jetbrains.spek:spek-junit-platform-engine:1.0.89'
compile 'de.hdodenhof:circleimageview:2.0.0'
kapt 'com.google.dagger:dagger-compiler:2.5'
compile 'com.google.dagger:dagger:2.5'
provided 'javax.annotation:jsr250-api:1.0'
compile 'pl.charmas.android:android-reactive-location:0.9@aar'
compile 'org.parceler:parceler-api:1.1.5'
apt 'org.parceler:parceler:1.1.5'
}
kapt {
generateStubs = true
}
// THIS MUST BE AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
The build of root.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// Load dependencies and configurations
apply from: 'config/dependencies.gradle'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "io.realm:realm-gradle-plugin:1.1.0"
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'http://oss.sonatype.org/content/repositories/snapshots' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@fabiocarballo It's an issue with the JUnit Platform plugin, see https://github.com/junit-team/junit5/issues/204. For now, you have to stick with the JUnit 4 based runner.
Remove these lines for now.
apply plugin: 'org.junit.platform.gradle.plugin'
junitPlatform {
engines {
include 'spek'
}
}
Do you have the @RunWith annotation?
On Fri, Sep 9, 2016 at 11:23 PM Fábio Carballo [email protected]
wrote:
@raniejade https://github.com/raniejade got it! that worked to compile
and recognize Spek. However, Android Studio isn't recognizing Spek class
files as tests as it was doing before. Anything I can do regarding this?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/JetBrains/spek/issues/117#issuecomment-245945868, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA_l_zwwDKTi0JpoDG0DYRQv2_KSpXnCks5qoXoDgaJpZM4J28Pt
.
Cheers,
Ranie Jade Ramiso
Software Engineer
w: http://polymorphicpanda.io
It was that! Sorry for the bother. Awesome work. I'm loving using Spek! :D
Most helpful comment
testRuntimeis only available if you apply gradle's standard java plugin. By any chance are you using the android plugin? If so,testCompileshould suffice.