Spek: Spek 2 IDEA Plugin and Android Studio 3.3 Canary 5

Created on 8 Aug 2018  路  5Comments  路  Source: spekframework/spek

I'm trying to get my specs converted from Spek 1 to 2. Manual Gradle (4.9) runs with ./gradlew test are working great, but running in Android Studio (3.3 Canary 5) with the Spek 2 plugin (2.0.0-alpha.1-IJ2018.1) gets me the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/spekframework/spek2/runtime/scope/PathBuilder
    at org.spekframework.ide.Spek2ConsoleLauncher.run(console.kt:13)
    at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt:34)
    at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt)
    at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody(SystemExitException.kt:74)
    at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody$default(SystemExitException.kt:72)
    at org.spekframework.ide.ConsoleKt.main(console.kt:32)
Caused by: java.lang.ClassNotFoundException: org.spekframework.spek2.runtime.scope.PathBuilder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

Here's what my setup looks like:

// build.gradle
buildscript {
    ext.kotlin_version = '1.3-M1'

    dependencies {
        classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.2.0.0'
    }
}

allprojects {
    repositories {
        maven { url 'https://dl.bintray.com/spekframework/spek-dev' }
    }
}
// app/build.gradle
apply plugin: 'de.mannodermaus.android-junit5'

android {
    testOptions {
        junitPlatform {
            filters {
                includeEngines 'spek2'
            }
        }
    }
}

dependencies {
    testImplementation('org.spekframework.spek2:spek-dsl-jvm:2.0.0-alpha.1') {
        exclude group: 'org.jetbrains.kotlin'
    }
    testRuntimeOnly('org.spekframework.spek2:spek-runner-junit5:2.0.0-alpha.1') {
        exclude group: 'org.jetbrains.kotlin'
    }
}

Here's the Android Studio version info:

_Android Studio 3.3 Canary 5
Build #AI-182.3684.101.33.4928781, built on August 2, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14_

I can't tell if this is an issue with the plugin/compatibility or something to do with my setup. Any clues? Thanks folks!

P.S. Thank you for Spek. It's waaaay more fun to write specs/tests with it!

Most helpful comment

Yup, that lets them run 馃憤 For you future readers, the dependency for kotlin-reflect needs to be a testImplementation dependency, too.

All 5 comments

The version of the plugin you have is for IJ, there's a different one for AS. The current AS plugin we have published only works for AS 3.2, I'll see what I can do.

Ah, gotcha. I realize 3.3 is still a canary build, so thank you! Things work on the command line for now, so at least I've got that.

@miketrewartha can you try changing testRuntimeOnly to testImplementation? I think there's a bug in the plugin where it's not including the dependencies from testRuntimeOnly. Android modules are the only ones affected.

Yup, that lets them run 馃憤 For you future readers, the dependency for kotlin-reflect needs to be a testImplementation dependency, too.

Looks like you've got #474 for this, so I'll close. Thanks @raniejade, appreciate the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raosuj picture raosuj  路  3Comments

svenjacobs picture svenjacobs  路  6Comments

mattbdean picture mattbdean  路  7Comments

pilgr picture pilgr  路  3Comments

robstoll picture robstoll  路  7Comments