Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Resource files not picked up in test variant #4

Open
realdadfish opened this issue Jul 9, 2014 · 10 comments
Open

Resource files not picked up in test variant #4

realdadfish opened this issue Jul 9, 2014 · 10 comments
Labels

Comments

@realdadfish
Copy link

Robolectric allows to place its configuration in a special config file org.robolectric.Config.properties that usually resides in src/test/resources. While this is correctly picked up when I execute ./gradlew test on command line, it isn't when I run the test through Android Studio.

@realdadfish realdadfish mentioned this issue Jul 9, 2014
@evant
Copy link
Owner

evant commented Jul 15, 2014

Right now, test resources are not supported at all.

@klassm
Copy link

klassm commented Aug 9, 2014

Hi,
is there any progress to that issue? I'd also need that feature :-)
Matthias

@evant
Copy link
Owner

evant commented Aug 9, 2014

@klassm No work so far. I do have a rough idea of what needs to be done.

@klassm
Copy link

klassm commented Aug 10, 2014

Well this would be absolutely a wonderful feature :-)

@evant
Copy link
Owner

evant commented Aug 25, 2014

I did make a bit of progress on this. Resource directories are now marked correctly if you are on the latest version of the gradle plugin. However, they are still not added to the classpath. I think its because the build dir is set up differently than a standard java project due to flavors. I can't seem to find a way to modify the classpath of the test runner to account for this. If you are really dieing for this feature, you could probably hack something together with a task that copies the resources into test-classes.

@evant
Copy link
Owner

evant commented Sep 14, 2014

@tommyd3mdi @klassm This will probably never be implemented because it requires recreating the entire classpath for the junit test runner. Intellij 14 has a new gradle test runner that solves this (and several other problems). So your best bet is to use that, or wait until the changes get rolled into Android Studio.

@evant evant added wontfix and removed enhancement labels Sep 14, 2014
@evant evant closed this as completed Sep 14, 2014
@klassm
Copy link

klassm commented Sep 15, 2014

Ok great. Thanks!

@evant
Copy link
Owner

evant commented Sep 15, 2014

Reopening so others can find it.

@ffgiraldez
Copy link

Actually (AS 1.0-RC) the main resource folder it's find correctly, but their flavor counterpart not

@polson
Copy link

polson commented Dec 8, 2014

You can fix this by copying the test resources via build.gradle:

//Copy test resources to classpath folder. See https://code.google.com/p/android/issues/detail?id=74443
tasks.findByName("assembleDebug").dependsOn("copyTestResources")
task copyTestResources(type: Copy) {
    from "${projectDir}/src/testDebug/resources"
    into "${buildDir}/test-classes/debug/resources"
}

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

No branches or pull requests

5 participants