-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Espresso tests - could they be placed outside the app src folder? #2
Comments
Thanks for your complimentary words. Short, yes it is possible and already done https://github.com/stephanenicolas/Quality-Tools-for-Android I tried it months ago but a co worker implemented the default version earlier. So I found no reason to try it further. For some additional testing I like also to proof wether it is possible with new build tool versions. We have different stages with different possibilities to setup test data. So for need different kind of tests for live server and server in our dev stages. |
I feel i'm close to a solution. Current i hang on the situation, that AcceptanceTest module will build his own APK. Thats would be ok (ignoring extra compile time) but i didn't find a way to include AndroidSample res into APK current. A different approach is to reuse the generated APK by AndroidSample (preferred solution), but here i can't find a way to disable APK generation task at AcceptanceTest module. Without it would not override the APK generated by AndroidSample, where all classes and res are included. i can use: |
Thanks! I will attempt a solution on my own as well. |
here is my build.gradle after moving espresso to a submodule for the version where it should use the already generated APK from main module. but not working current. https://gist.github.com/nenick/3820d89cd66570f86204 |
Interesting. Thanks for sharing that, will try soon. |
version with recompile app sources for module with espresso tests works. it was just a path naming issue where i forgot to rename the module name to AndroidSample. the gist is updated and can be used in a own module. drawbacks: recompile and in android studio it looks ugly with - ModuleName (resources root) but it should still be possible to avoid the ugly stuff when we could reuse apk from the main module. |
it looks like it wasn't the intention to use espresso in own modules, so you should ask this guys to support it without ugly drawbacks and configurations effort |
Still trying to get mine to work. Let me summarize what you seemed to do: You created a new build.gradle file in a sub folder.
|
Yes you are right.
Dependencies are added mostly for android studio. He thinks now that AndroidSample/src/main belongs to the other module, because gradle.build say it. That is the real ugly part of this solution. |
I have mine setup much like yours. But when I do this command: .gradlew assembleDebugTest instead of using the new build.gradle file in the sub module, it uses the one in the main Android folder - and produces a nearly empty test apk. |
Hehe maybe it didn't find a test class ;) |
Maybe wrong call (try with :subfolder:assemble... or missing entry in settings.gradle? |
I finally got it to work. For everyone reading this who wants to know I did the following:
./gradlew :tests:assembleDebug -> builds APK for app; not necessary exactly but it does it Thank you, Nico, for giving me so many tips on how to accomplish this. |
Impressed by this sample project and how you have all 3 levels of tests working along with Jacoco. I've learned a lot by looking at your code and organization of modules.
One thing I really liked: how you put ComponentTestsRobolectric and UnitTestsRobolectric as folders on the same level as AndroidSample. You did a great job of showing how the build.gradle files in sub folders relate to the master build.gradle file and how Jacoco can point to the directory ../AndroidSample for the code coverage.
However, in AndroidSample you have the src folder with main and test subfolders; test subfolder has espresso/instrumentation tests.
Do you think it is possible to move the Instrumentation tests to a subfolder on the same level as the others? I would prefer to have InstrumentationTests folder alongside Unit/Component.
The text was updated successfully, but these errors were encountered: