spekframework / spek

A specification framework for Kotlin
Other
2.23k stars 179 forks source link

Setup instructions for Maven are incomplete #192

Closed yay closed 5 years ago

yay commented 7 years ago

Clearly, that's not all it takes to set up Spek with Maven: http://spekframework.org/docs/latest/#_maven

Please provide detailed instructions for "dummies".

I have the following in my <pom.xml> and I still get Unresolved reference for Spek and the IDE can't auto-import the package(s):

        <properties>
             ...
             <spek.version>1.1.0-beta4</spek.version>
             <junit.platform.version>1.0.0-M3</junit.platform.version>
        </properties>

        ...
   <dependencies>
        ...
        <dependency>
            <groupId>org.jetbrains.spek</groupId>
            <artifactId>spek-api</artifactId>
            <version>${spek.version}</version>
            <!--<scope>test</scope>-->
        </dependency>

        <dependency>
            <groupId>org.jetbrains.spek</groupId>
            <artifactId>spek-junit-platform-engine</artifactId>
            <version>${spek.version}</version>
        </dependency>

        <dependency>
            <groupId>org.amshove.kluent</groupId>
            <artifactId>kluent</artifactId>
            <version>1.4</version>
        </dependency>

        <!--Public API for test engines. -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-engine</artifactId>
            <version>${junit.platform.version}</version>
        </dependency>
    </dependencies>

<build>
        <plugins>
              <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>${junit.platform.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
hhariri commented 7 years ago

Can I see you repositories definition?

yay commented 7 years ago

Here is it:

    <repositories>
        <repository>
            <id>kotlin-eap</id>
            <url>http://dl.bintray.com/kotlin/kotlin-eap-1.1</url>
        </repository>
        <repository>
            <id>kotlin-exposed</id>
            <url>https://dl.bintray.com/kotlin/exposed</url>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
        <repository>
            <id>maven.oracle.com</id>
            <name>oracle-maven-repo</name>
            <url>https://maven.oracle.com</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
        </repository>
        <repository>
            <id>sonatype-oss-snapshot</id>
            <snapshots/>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
        <repository>
            <id>org.jetbrains.spek</id>
            <url>http://dl.bintray.com/jetbrains/spek</url>
        </repository>
    </repositories>
hhariri commented 7 years ago

OK can't see anything specifically wrong here. Is there a chance for you to send me your entire POM so I can take a look?

yay commented 7 years ago

No problem, here you go: pom.xml.zip

yay commented 7 years ago

OK, 1.1.0-beta3 and 1.1.0-beta2 work with both Maven repo and BinTray repo, but 1.1.0-beta4 jar is loaded but empty.

yay commented 7 years ago

A friend of mine tried it, and it worked well for him, so I just used his jar that he sent me. But this is really weird. I tried with both built in Maven and the Maven I had installed via Homebrew (both v3.3.9), but with same "success". Both downloaded a corrupted jar (couldn't unzip it and the size was just 2Kb).

raniejade commented 7 years ago

@yay can you try using the latest release 1.1.0?

yay commented 7 years ago

Maybe at some future point, I've decided to use JUnit 4 for now. Thanks for looking.

deinspanjer commented 7 years ago

I'm sorta in the same boat. Using Kotlin, IntelliJ IDEA, Maven, and Spek 1.1.1.

So far, I tried adding the dependency for spek-api as documented, and then I tried several variants of adding dependencies for spek-junit-platform-engine, junit-platform-launcher, and the Spek plugin for IntelliJ.

Here is what I currently get when I try to run a test:

/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java -Dvisualvm.id=330246125180908 "-javaagent:/Users/dre/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61916:/Users/dre/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/tools.jar:/Users/dre/src/jsonlogic-java/target/test-classes:/Users/dre/src/jsonlogic-java/target/classes:/Users/dre/.m2/repository/com/github/salomonbrys/kotson/kotson/2.5.0/kotson-2.5.0.jar:/Users/dre/.m2/repository/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.0.6/kotlin-stdlib-1.0.6.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-runtime/1.0.6/kotlin-runtime-1.0.6.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-test/1.0.5-2/kotlin-test-1.0.5-2.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-runtime/1.0.5-2/kotlin-runtime-1.0.5-2.jar:/Users/dre/.m2/repository/org/jetbrains/spek/spek-junit-platform-engine/1.0.0-test-deploy/spek-junit-platform-engine-1.0.0-test-deploy.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.0.2/kotlin-stdlib-1.0.2.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.0.2/kotlin-reflect-1.0.2.jar:/Users/dre/.m2/repository/org/jetbrains/spek/spek-api/1.0.0-test-deploy/spek-api-1.0.0-test-deploy.jar:/Users/dre/.m2/repository/org/junit/platform/junit-platform-launcher/1.0.0-M4/junit-platform-launcher-1.0.0-M4.jar:/Users/dre/.m2/repository/org/junit/platform/junit-platform-engine/1.0.0-M4/junit-platform-engine-1.0.0-M4.jar:/Users/dre/.m2/repository/org/junit/platform/junit-platform-commons/1.0.0-M4/junit-platform-commons-1.0.0-M4.jar:/Users/dre/.m2/repository/org/opentest4j/opentest4j/1.0.0-M2/opentest4j-1.0.0-M2.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.2-3/kotlin-stdlib-jre8-1.1.2-3.jar:/Users/dre/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.2-3/kotlin-stdlib-jre7-1.1.2-3.jar:/Users/dre/Library/Application Support/IntelliJIdea2017.1/spek-idea-plugin/lib/tooling-0.3.4.jar" org.jetbrains.spek.tooling.MainKt --spec com.jsonlogic.JsonLogicSpec
Testing started at 6:35 PM ...
objc[91146]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/engine/discovery/ClasspathSelector
    at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:48)
    at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:36)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:115)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:87)
    at org.junit.platform.launcher.Launcher.execute(Launcher.java:93)
    at org.jetbrains.spek.tooling.runner.junit.JUnitPlatformSpekRunner.run(JUnitPlatformSpekRunner.kt:107)
    at org.jetbrains.spek.tooling.MainKt.main(Main.kt:58)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.discovery.ClasspathSelector
    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)
    ... 7 more

Process finished with exit code 1

Could you provide a sample Maven pom or full instructions for getting Spek running inside IntelliJ IDEA with a simple Hello World app?

pemistahl commented 6 years ago

See issue 322 for a working sample.