Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Error while running robolectric test. [java.lang.IllegalArgumentException: File does not exist: ./android-all-5.0.0_r2-robolectric-1.jar] #807

Closed
raviagarwal7 opened this issue Jul 14, 2016 · 6 comments

Comments

@raviagarwal7
Copy link
Contributor

buck target setup:

android_library(
    name = 'src_release',
    srcs = glob([
        'src/main/java/**/*.java',
    ]),
    ...
)

robolectric_test(
    name = 'test_release',
    srcs = glob([
        'src/test/java/**/*.java',
    ]),
    provided_deps = [   
        '//.okbuck/cache/7a34c38a1121381f1e93352a2e1015f8:android-all-5.0.0_r2-robolectric-1.jar',
        ...
    ],
    deps = [
        ':src_release',
        '//.okbuck/cache/1dd108c6fe3765cf2c95f8b239624462:robolectric-3.0.2.jar',
        '//.okbuck/cache/c7cb9b9abec440b35578232b55381fbb:robolectric-annotations-3.0.jar',
        '//.okbuck/cache/f71543558afca2c4d42852c2c7c47fe0:robolectric-resources-3.0.jar',
        '//.okbuck/cache/caf749e74deb6ca3462532b51d393514:robolectric-utils-3.0.jar',
        ...
    ]
    ...
)

when trying to test test_release getting File does not exist error, stack trace below:

java.lang.IllegalArgumentException: File does not exist: ./android-all-5.0.0_r2-robolectric-1.jar
    at org.robolectric.internal.dependency.LocalDependencyResolver.validateFile(LocalDependencyResolver.java:55)
    at org.robolectric.internal.dependency.LocalDependencyResolver.getLocalArtifactUrl(LocalDependencyResolver.java:32)
    at org.robolectric.internal.dependency.LocalDependencyResolver.getLocalArtifactUrls(LocalDependencyResolver.java:40)
    at org.robolectric.internal.InstrumentingClassLoaderFactory.getSdkEnvironment(InstrumentingClassLoaderFactory.java:39)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:187)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    at com.facebook.buck.testrunner.JUnitRunner.run(JUnitRunner.java:135)
    at com.facebook.buck.testrunner.BaseRunner.runAndExit(BaseRunner.java:219)
    at com.facebook.buck.testrunner.JUnitMain.main(JUnitMain.java:47)
    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.facebook.buck.jvm.java.runner.FileClassPathRunner.main(FileClassPathRunner.java:87)

robolectric.offline is being set to true in buck - RobolectricTest.java#L172
but we are not setting robolectric.dependency.dir which is required in offline mode. (http://robolectric.org/configuring/).

what other configuration robolectric_test requires to make it work?

@raviagarwal7 raviagarwal7 changed the title Error while running robolectric test. (java.lang.IllegalArgumentException: File does not exist: ./android-all-5.0.0_r2-robolectric-1.jar) Error while running robolectric test. [java.lang.IllegalArgumentException: File does not exist: ./android-all-5.0.0_r2-robolectric-1.jar] Jul 14, 2016
@raviagarwal7
Copy link
Contributor Author

cc: @kageiit

@raviagarwal7
Copy link
Contributor Author

note: all java test under test_release works fine, only robolectric tests fails.

@Coneko
Copy link

Coneko commented Jul 14, 2016

cc @alsutton

@Coneko
Copy link

Coneko commented Jul 14, 2016

cc @marcinkosiba

@marcinkwiatkowski
Copy link
Contributor

@raviagarwal7 You can pass robolectric.dependency.dir as vm_args in robolectric_test rule.

You will also need a few more jars:
android-all-5.0.0_r2-robolectric-1.jar
json-20080701.jar
shadows-core-3.0-21.jar
tagsoup-1.2.jar

@raviagarwal7
Copy link
Contributor Author

@marcinkwiatkowski created a pull request - #878

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants