I am using Robolectric and the "android-unit-test" plugin in my android project. I have multiple modules (eg foo
and bar
) and would like to use the same test runner across all the modules. To achieve this I created a Test
module to hold my test runner and any custom shadow classes. In foo's build.gradle I have testCompile project (":main:Test")
however android studio will not import my runner unless I also include androidTestCompile (":main:test")
. Furthermore, when I run ./gradlew test
from the command line I get various errors saying that my test runner and shadow classes cannot be found. Anyone have any advice?
With your given information I guess you missed one little aspect: test classes appear not in jars.
When your shared TestRunner is under src/test/java
then other modules will not see it. When I'm correct then place you TestRunner at src/main/java
and all modules should have access to our support classes.
Here is also an example where i did the same https://github.com/nenick/AndroidAppDevelopment
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.