{"action":"created","issue":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/1896","labels_url":"https://api.github.com/repos/robolectric/robolectric/issues/1896/labels{/name}","comments_url":"https://api.github.com/repos/robolectric/robolectric/issues/1896/comments","events_url":"https://api.github.com/repos/robolectric/robolectric/issues/1896/events","html_url":"https://github.com/robolectric/robolectric/issues/1896","id":88477991,"number":1896,"title":"AndroidManifest.xml and assets not found for RobolectricGradleTestRunner in Android Studio","user":{"login":"feantury","id":2143931,"avatar_url":"https://avatars.githubusercontent.com/u/2143931?v=3","gravatar_id":"","url":"https://api.github.com/users/feantury","html_url":"https://github.com/feantury","followers_url":"https://api.github.com/users/feantury/followers","following_url":"https://api.github.com/users/feantury/following{/other_user}","gists_url":"https://api.github.com/users/feantury/gists{/gist_id}","starred_url":"https://api.github.com/users/feantury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feantury/subscriptions","organizations_url":"https://api.github.com/users/feantury/orgs","repos_url":"https://api.github.com/users/feantury/repos","events_url":"https://api.github.com/users/feantury/events{/privacy}","received_events_url":"https://api.github.com/users/feantury/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-15T16:40:52Z","updated_at":"2015-06-16T02:00:08Z","closed_at":null,"body":"I am trying to create a test for my Application class, so I set it in the config like:\r\n```java\r\n@RunWith(RobolectricGradleTestRunner.class)\r\n@Config(application = MyApplication.class, constants = BuildConfig.class)\r\n```\r\nThe problem comes on how to run them in the Android Studio. We have two options:\r\n- Using a gradle task (needed for CI).\r\n- Using the jUnit built-in test runner (day a day testing in the IDE).\r\n\r\nI want both to work in my project but there is a problem that comes up always. When I run it from Android Studio jUnit built-in system, Intellij sets the working directory to my root project, not the module. Of course we can change it to $MODULE_DIR$ but there is a well known issue that makes all tests to pass even if they have failed and the debugger is not allowed when this variable is set, so not an option.\r\n\r\nSo the situation is:\r\n- We run it from Android Studio jUnit -> Working directory is the root project.\r\n- We run it from Gradle -> Working directory depends where you execute it.\r\n\r\nSince the root can change, the manifest location is not found for both situations as it is static in @Config and not controlled in RobolectricGradleTestRunner.\r\n\r\nBeside that, assets folder is not found it we place it in a test folder because RobolectricGradleTestRunner tries to find it in the assembled files.\r\n\r\nSo, to sum up all the problems with this runner:\r\n- Working directory is not consistent and we cannot locate de manifest always in the same dir. Sometimes it is ./moduleName/src/test..., sometimes it is ./src/test...\r\n- Assets located in the test folder cannot be found\r\n- @Config configuration for manifest is ignored for RobolectricGradleTestRunner because it does not call the super implementation\r\n\r\nPlease let me know if you need more information."},"comment":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/comments/112258922","html_url":"https://github.com/robolectric/robolectric/issues/1896#issuecomment-112258922","issue_url":"https://api.github.com/repos/robolectric/robolectric/issues/1896","id":112258922,"user":{"login":"jaredsburrows","id":1739848,"avatar_url":"https://avatars.githubusercontent.com/u/1739848?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredsburrows","html_url":"https://github.com/jaredsburrows","followers_url":"https://api.github.com/users/jaredsburrows/followers","following_url":"https://api.github.com/users/jaredsburrows/following{/other_user}","gists_url":"https://api.github.com/users/jaredsburrows/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredsburrows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredsburrows/subscriptions","organizations_url":"https://api.github.com/users/jaredsburrows/orgs","repos_url":"https://api.github.com/users/jaredsburrows/repos","events_url":"https://api.github.com/users/jaredsburrows/events{/privacy}","received_events_url":"https://api.github.com/users/jaredsburrows/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T02:00:08Z","updated_at":"2015-06-16T02:00:08Z","body":"## 1:\r\n`@Config(application = MyApplication.class, constants = BuildConfig.class)`\r\n\r\nyou should be using:\r\n\r\n`@Config(constants = BuildConfig.class)`\r\n\r\n## 2:\r\nWith this big post, you didn't even share a way for us to reproduce this \"error\" or \"issue\". Please share an example test.\r\n\r\n## 3:\r\nFocus on getting `Gradle` to work, not the `IDE`.\r\n\r\n## 4:\r\nWhy are you putting an `assets` in the test folder? Are you changing your app's assets?"}}