Comments (13)
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.
from android-gradle-template.
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: assembleDebug.enabled = false
and task will be skipped
but looks like APK is generated by packageDebug
. (which works not)
from android-gradle-template.
Thanks! I will attempt a solution on my own as well.
from android-gradle-template.
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
from android-gradle-template.
Interesting. Thanks for sharing that, will try soon.
from android-gradle-template.
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.
from android-gradle-template.
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
from android-gradle-template.
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.
The content of the build.gradle was much the same as the one in AndroidSample, and I noted these things:
- You removed apt
- You removed buildTypes section
- I see instrumentTest rather than androidTest but that's just a typo.
- dependencies for androidTest, such as espresso
- You kept all the compile dependencies for Android Sample --> so it can compile APK for AndroidSample in addition to instrumented APK?
- sourceSets directories point back to ../AndroidSample/src/... --> because an instrumented APK needs to refer back to the source I assume?
from android-gradle-template.
Yes you are right.
- Module with given build.gradle
- move src/test to new module.
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.
from android-gradle-template.
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.
from android-gradle-template.
Hehe maybe it didn't find a test class ;)
rename test folder to androidTest and try again
from android-gradle-template.
Maybe wrong call (try with :subfolder:assemble... or missing entry in settings.gradle?
from android-gradle-template.
I finally got it to work. For everyone reading this who wants to know I did the following:
- Created a folder called "tests" at same level/depth as app.
- My test source was in src/androidTest/java
- Copied over build.gradle from app folder into tests
- Remove build targets not needed from build.gradle
- Added androidTestCompile dependencies
./gradlew :tests:assembleDebug -> builds APK for app; not necessary exactly but it does it
./gradlew :tests:assembleDebugTest -> builds Test APK with instrumentation
Thank you, Nico, for giving me so many tips on how to accomplish this.
from android-gradle-template.
Related Issues (20)
- Project Structure Question HOT 1
- A problem occurred evaluating project ':ComponentTestsRobolectric' HOT 6
- When using this template, I've faced some problems HOT 3
- jacoco with espresso, task jacocoTestReport skipped HOT 6
- Error Illegal use of non virtual function call HOT 4
- Maybe switch to JCAndKSolutions/android-unit-test
- 'android' or 'android-library' plugin is required HOT 8
- Illegal use of nonvirtual function call HOT 2
- Collect code coverage during manual testing? HOT 2
- Update to latest version of Espresso and Mockito? HOT 3
- Voting: Which is your favourite way to support robolectric? HOT 5
- Can not compile success in the environment Android Studio1.0+ gradle2.2.1+build gradle1.0 HOT 3
- Unexpected top-level exception when running app HOT 2
- Could not find com.novoda:gradle-android-test-plugin:0.10.3. HOT 3
- run-tests.sh needs a simple fix HOT 1
- Android Studio 1.4 Java modules cannot depend on Android modules HOT 2
- FileNotFound Exception HOT 8
- Running / debugging Unit or Component tests in Android Studio HOT 3
- Unable to import project HOT 5
- oops
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-gradle-template.