spek
spek copied to clipboard
Robolectric integration
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?
+1
+1
+1
+1
+1
+1
+1
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 [email protected] 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 .
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
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
@JackED42 see InstanceFactory
and @CreateWith
since most likely you will need to use custom class loaders.
+1
+1
+1
+1
+1
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.
@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.
@bangarharshit hello, have you made the implementation or support for RoboElectric
really would be very interesting, thanks in advance
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.
What happened to this? Does Spek to Robolectric integration work?