Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support object instance tests #109

Closed
mfulton26 opened this issue Aug 26, 2016 · 2 comments
Closed

Support object instance tests #109

mfulton26 opened this issue Aug 26, 2016 · 2 comments
Assignees
Milestone

Comments

@mfulton26
Copy link

IntelliJ IDEA offers to run object speks annotated with @RunWith(JUnitPlatform::class) but running such results in a KotlinNullPointerException. I personally like using object for tests/specifications as they are indeed singletons (unless data driven, but that usually happens within a test/specification and not at the top-level and if it does then enum/class can be used with whatever annotations/etc. the framework supports for driving such).

@RunWith(JUnitPlatform::class)
object ExampleSpek : Spek({
    group("a") {
        test("1") {}
        test("2") {}
    }
    group("b") {
        group("1") {
            test("A") {}
        }
        group("2") {
            test("A") {}
            test("B") {}
        }
    }
})
Aug 26, 2016 10:49:17 AM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
INFO: Discovered TestEngines with IDs: [spek]

kotlin.KotlinNullPointerException
    at org.jetbrains.spek.engine.SpekTestEngine.resolveSpec(SpekTestEngine.kt:97)
    at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:62)
    at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:36)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:108)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:78)
    at org.junit.platform.runner.JUnitPlatform.generateTestTree(JUnitPlatform.java:113)
    at org.junit.platform.runner.JUnitPlatform.<init>(JUnitPlatform.java:96)
    at org.junit.platform.runner.JUnitPlatform.<init>(JUnitPlatform.java:88)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:96)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
@raniejade
Copy link
Member

Good point, thanks! We will look into it after the 1.0 release.

@raniejade raniejade added this to the 1.1 milestone Dec 4, 2016
@raniejade raniejade self-assigned this Dec 4, 2016
This was referenced Dec 17, 2016
@raniejade
Copy link
Member

Resolved by b9967f3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants