help need with installation issue - not working!

29 views
Skip to first unread message

Edward Austin

unread,
Oct 8, 2015, 7:52:58 PM10/8/15
to robolectric

Pulled the library in for Gradle OK (3.0)
Excuse the brevity here but simply demonstrating the issue.

@RunWith(RobolectricGradleTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21, constants = BuildConfig.class)
public class PrimaryActivityTest {
@Test(timeout=2000)
public void fooBar() {

Activity activity = Robolectric.setupActivity(MyActivity.class);
//rest of code
}

Once the activity line is reached the process hangs (and my machine crawls to a halt, 100% CPU).

All Standard Vanilla JUnit/Mockito unit tests before this go green/pass as normal, so it is this particular test (and code) that I believe to be the problem. I have only ever previously tested/mocked non Droidy stuff but now need to test a bit more in depth.

Placing the timeout just expires and terminates the process as otherwise system becomes unresponsive.

Configuration is as I have read in various places, it's hard to get solid information on this.

Many thanks guys.

Ed



The timeout stacktrace:

org.junit.runners.model.TestTimedOutException: test timed out after 20 milliseconds
at java.util.zip.Inflater.inflateBytes(Native Method)
at java.util.zip.Inflater.inflate(Inflater.java:259)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:152)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.robolectric.util.Util.copy(Util.java:21)
at org.robolectric.util.Util.readBytes(Util.java:38)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.getByteCode(InstrumentingClassLoader.java:170)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.findClass(InstrumentingClassLoader.java:123)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:95)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.findClass(InstrumentingClassLoader.java:153)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:95)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.findClass(InstrumentingClassLoader.java:153)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:95)
at ru.ryer.test.testapplication.PrimaryActivityTest.fooBar(PrimaryActivityTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.lang.Thread.run(Thread.java:745)



Erich Douglass

unread,
Oct 12, 2015, 5:25:39 PM10/12/15
to robolectric
Hi Edward,

The first time you run Robolectric, it downloads some jars that it needs to run your tests (based on the API level you are targeting). The only thing I can think of is that it was downloading the jars and appeared hung. It should only do this the first time you run against an API level that Robolectric doesn't have the code for.

--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages