spekframework / spek

A specification framework for Kotlin
Other
2.22k stars 180 forks source link

Robolectric integration #65

Open dmarcato opened 8 years ago

dmarcato commented 8 years ago

Currently, Spek doesn't play well with Robolectric :disappointed:

The reason is that Robolectric requires a BlockJUnit4ClassRunner, but Spek requires its own JUnitClassRunner. The exception thrown is:

java.lang.Exception: No runnable methods
    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
    at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:78)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    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:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Would it be possible to support framework like Robolectric?

jaredsburrows commented 8 years ago

+1

ChrisZou commented 8 years ago

+1

kiharakato commented 8 years ago

+1

pivotal-james-zcheng commented 8 years ago

+1

d-lorenc commented 8 years ago

+1

temporaryna commented 8 years ago

+1

Spoki4 commented 8 years ago

+1

artem-zinnatullin commented 8 years ago

Not a Robolectric user at the moment, can't you just extend RobolectricTestRunner and add functionality of JUnitSpekRunner to it?

On Mon, Aug 8, 2016 at 7:52 PM, Ivan notifications@github.com wrote:

+1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JetBrains/spek/issues/65#issuecomment-238298607, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7B3DnUI_Bf5Wv0N31NDwq7atXPtC8tks5qd17RgaJpZM4HjK-5 .

lordspace74 commented 8 years ago

+1

nomisRev commented 8 years ago

+1

Dima564 commented 7 years ago

+1

AndriyBas commented 7 years ago

+1

KolomietsOleh commented 7 years ago

+1

fullkomnun commented 7 years ago

+1

rafaelsm commented 7 years ago

+1

mht-yu-iimura commented 7 years ago

+1

davidcrotty commented 7 years ago

+1

89jd commented 7 years ago

+1

89jd commented 7 years ago

Does anyone have any ideas on an implementation of having Spek work with RoboElectric. I have tried to take a look, but I am a bit lost... If someone can point me in the right direction, I am happy to see what I can do

Thanks

raniejade commented 7 years ago

@JackED42 see InstanceFactory and @CreateWith since most likely you will need to use custom class loaders.

paganaye commented 7 years ago

+1

bl-lia commented 7 years ago

+1

crow-misia commented 7 years ago

+1

t28hub commented 7 years ago

+1

dave08 commented 6 years ago

+1

bangarharshit commented 6 years ago

I can add support for robolectric by writing a custom test engine (it will be a copy of Robolectric's test runner). There will be few limitations such as configs per test since I don't know how can we annotate a test in spek.

raniejade commented 6 years ago

@bangarharshit thanks, as much as possible we prefer to decouple the implementation from JUnit. The idea is to implement it using Spek's API. We provide @CreateWith probably a good place to start.

amed500 commented 6 years ago

@bangarharshit hello, have you made the implementation or support for RoboElectric really would be very interesting, thanks in advance

bangarharshit commented 6 years ago

The pr is almost ready. I will be adding tests and test with different Android configurations before sending the PR. Definitely by end of this week.

thsaravana commented 4 years ago

What happened to this? Does Spek to Robolectric integration work?

raniejade commented 4 years ago

Looks like it fell out of interest. I'm not an android developer, so I don't know how to implement this properly. Would really appreciate someone doing android development pick this up.

xian commented 4 years ago

Planning to look at this soon.

xian commented 4 years ago

Underway here: https://github.com/robolectric/robolectric/pull/5520