Code Monkey home page Code Monkey logo

Comments (13)

nenick avatar nenick commented on August 23, 2024

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.

nenick avatar nenick commented on August 23, 2024

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.

RichardGuion avatar RichardGuion commented on August 23, 2024

Thanks! I will attempt a solution on my own as well.

from android-gradle-template.

nenick avatar nenick commented on August 23, 2024

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.

RichardGuion avatar RichardGuion commented on August 23, 2024

Interesting. Thanks for sharing that, will try soon.

from android-gradle-template.

nenick avatar nenick commented on August 23, 2024

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.

nenick avatar nenick commented on August 23, 2024

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.

RichardGuion avatar RichardGuion commented on August 23, 2024

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.

nenick avatar nenick commented on August 23, 2024

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.

RichardGuion avatar RichardGuion commented on August 23, 2024

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.

nenick avatar nenick commented on August 23, 2024

Hehe maybe it didn't find a test class ;)
rename test folder to androidTest and try again

from android-gradle-template.

nenick avatar nenick commented on August 23, 2024

Maybe wrong call (try with :subfolder:assemble... or missing entry in settings.gradle?

from android-gradle-template.

RichardGuion avatar RichardGuion commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.