Coder Social home page Coder Social logo

artem-zinnatullin / qualitymatters Goto Github PK

View Code? Open in Web Editor NEW
1.8K 75.0 206.0 7.05 MB

Android Development Culture

Home Page: https://artemzin.com/blog/android-development-culture-the-document-qualitymatters/

License: Apache License 2.0

Java 99.66% Shell 0.34%

qualitymatters's Introduction

QualityMatters

This app follows all principles of Android Development Culture Document.

What does it have:

  • CI (Travis)
  • Unit tests (some are Robolectric, some are plain JUnit tests with mocked android.jar).
  • Integration tests to see that HTTP, REST, JSON parsing and RxJava work well in composition.
  • Functional (UI) tests (Espresso with custom rules, mocked server and Screen-architecture) to check that app works according to the expectations from the user's point of view.
  • Static code analysis (FindBugs, PMD, Android Lint, Checkstyle) (see root build.gradle).
  • Code coverage codecov.io
  • Developer Settings Menu where you can enable/disable Stetho, LeakCanary, etc. See full list below (feel free to add more tools!).
  • Git sha & build time without breaking incremental compilation! (Thanks to Paperwork)
  • MVP, RxJava, Dagger 2, Retrofit 2 and so on.

Made with ❤️ by Artem Zinnatullin https://twitter.com/artem_zin.

To build the project run sh build.sh (yep, that easy, because it should be easy).

Screenshots:

Tests

Unit tests

Unit tests live mostly in src/unitTests but the app also has debug and release specific code—so there are also debugUnitTests and releaseUnitTests.

Unit tests check classes/methods in isolation from others, all dependencies are mocked.

All unit tests run on the JVM, no emulator or device is required. Mostly, unit tests run with mocked android.jar (built-in feature of Android Gradle Plugin). Some tests require things like Intent, etc. and such tests run using Robolectric.

The app has custom unit test runner which is required in order to override and mock some dependencies using Robolectric, like Analytics. Who needs real Analytics in Unit tests?

Integration tests

Integration tests live in src/integrationTests.

Integration tests check composition of multiple classes, for example OkHttp + Retrofit + Jackson + RxJava == API level, mostly all classes are real and not mocked, but for instance, we mock web server in integration tests.

All integration tests run on the JVM using Robolectric.

Also, you might notice that the app has custom integration test runner. It's required in order to override and mock some dependencies, like Analytics. Again, who needs real Analytics in integration tests?

Functional (UI) tests

The app has functional (UI) tests that live in src/functionalTests.

Functional tests check how the product (Android app) works from user's point of view. Basically, functional tests check app's UI for different use cases.

All functional tests run on connected emulator/device via Instrumentation API.

Also, you might notice that the app has custom functional test runner (yep). It's required to override and change implementation of some dependencies, like Analytics—instead of posting tons of useless data to Analytics during functional tests, we simply output it to the LogCat!

Developer Settings

Tools:

  • Stetho — inspect the app via Chromium Developer Tools (network requests, db, preferences and so on). Must-have for developers.
  • LeakCanary — detect memory leaks without IDE! Must-have for QAs and developers.
  • TinyDancer — see frame rate right on your screen. Must-have for QAs and developers.
  • Lynx — see LogCat output right in the app, useful for QAs and developers.

Details of implementation

Developer Settings are present only in debug build type. Libraries and resources used for Developer Settings are compiled into debug build only—main source set knows only little abstractions over Developer Settings just to initialize real implementation in the debug build code. In release build type DeveloperSettingsModule (Dagger) just returns no-op implementation of DeveloperSettingsModel.

Why only debug builds? The answer is simple — dex limit. LeakCanary brings about 3k methods, Stetho brings about 2k and so on. The more tools you add to Developer Settings, the bigger the apk you receive. Situation is even worse if your main code gets near 65k methods. In our production app we had to turn on multidex for debug builds.

Package structure

Many people ask why this app has component-based package structure: presenters, models, etc. instead of the feature-based one: itemslist, developersettings, etc.

With component-based structure of packages, new persons on the project (like those who read the code of this app) can easily find presenters, views, models, etc. within the app. If you read the code and want to quickly move to some class related to the current one you can simply press t right on the GitHub and search for the required file!

qualitymatters's People

Contributors

arazabishov avatar artem-zinnatullin avatar asriram3 avatar codeteo avatar danielgomezrico avatar digitalbuddha avatar dmitriyzaitsev avatar egor-n avatar ilya-gh avatar jasonjyu avatar jcminarro avatar jshvarts avatar jvilya avatar kimar avatar kirillmakarov avatar lenguyenthanh avatar omihaz avatar plastix avatar serj-lotutovici avatar skoric avatar vanniktech avatar zsavely avatar zsoltk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qualitymatters's Issues

Release not recognized as a valid source set

For some reason the release code and release unit tests are not recognized by my version of Android studio (2.0-Beta7).

screen shot 2016-03-19 at 12 55 35 pm

This makes it impossible to run the release unit tests. I've noticed that the release build type in the gradle config is missing an id. However adding this back in doesn't solve the problem. Any ideas?

buildTypes { 
    ...
    release {
            signingConfig signingConfigs.qualityMatters
            applicationIdSuffix '.release' // Missing from build.gradle!!
            ...
    }

Repo as "Awesome"

Hey

Also maybe this repo can be renamed to "Awesome android app" or something since its a refined list of tools and settings all inside one app, also may help to give visibility to this.

Check https://github.com/sindresorhus/awesome

And just wanted to share this awesome with cool plugins/tools/things/any for mobile learning and best practices...

https://github.com/MakinGiants/awesome-mobile-dev

Its aligned with quality matters so maybe add it to readme here as reference or an update from you guys it with cool things learned from here or something will be "awesome" (lol).

Proguard release build

Idea behind this is to make project as much close to real world one as possible. In my practice release builds are usually proguarded because of code shrinking and performance improvements, let's make this for qualitymatters too?

Also, will be great to run functional tests both for non-proguarded and proguarded build types (this is possible).

// I'm currently very busy so I'll be more than happy if somebody will submit a PR for that, otherwise I'll do it someday.

Take a look at Spring Dependency management plugin

https://github.com/spring-gradle-plugins/dependency-management-plugin

When you want to provide dependency management for multiple modules with the same group and version you should use a dependency set. Using a dependency set removes the need to specify the same group and version multiple times:

dependencyManagement {
     dependencies {
          dependencySet(group:'org.slf4j', version: '1.7.7') {
               entry 'slf4j-api'
               entry 'slf4j-simple'
          }
     }
}

Could be a nicer way to define dependencies especially for things like the android support libraries

Code Quality Tools: PMD

I really do like to use PMD as it catches some stuff that neither Checkstyle nor Findbugs does.

If you want me to, I could also add that one, we'd just then need to agree on some rules as there are quite a lot.

Get rid of Robolectric on DeveloperSettingsTest

As I see we are using Robolectric to test DeveloperSetting class because DeveloperSetting needs an instance of SharedPreferences.

Instead of user Robolectric to get SharedPreferences instance we can use some kind of mock or in memory Shared preferences. In my opinion, It will be better approach than using Robolectric.

Or we can use this instead of SharedPreferences directly on DeveloperSetting class. It will make mocking stuffs easy.

Document Developer Settings

Really liking the debug panel. I noticed it in Wharton's U2020, and was curious if yours is a clone or if you've modified it in some ways. I know there are a couple 3rd party libraries that are similar as well.
Would be nice to update the README to document it in some form.

[Question] Unresponsive/Flaky Roboelectric tests

I'm not sure if this is the correct forum for asking this question but I'll ask it anyway. Hopefully someone has some insight into the problem.

Is anyone else having issues running the unit tests that depend on Roboelectric? For some reason they hang indefinitely on my system.

See the following test screenshot from Android studio:
screen shot 2016-03-30 at 10 47 41 am

This problem makes it impossible for me to run unit tests that depend on Android SDK classes.

ItemVIewHolder click listeners

I see that you have ItemViewHolder as a separate class as opposed to an inner class of the adapter. I was wondering how would you implement a click listener without a reference to the adapter?

Add errorprone

Basically that tool automatically hooks itself up with the build process so even locally while developing you'll get warnings / errors. If it's fatal it'll give you an error during compiling.

Website for more information

If you want, I can also submit a PR for that in the next couple of days.

Gradle sync fails all the time

I'm running sh ci.sh and the project is built successfully.
However, Android Studio keeps showing me the following error message:

Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

Because whenever I try to sync Gradle project I'm getting the following error:

Error:(4, 0) Cause: hu/supercluster/paperwork/plugin/PaperworkPlugin : Unsupported major.minor version 52.0

I suppose that this may be caused by the incompatibility of bytecode generated by different java compilers. The JAVA_HOME on my system points to the Java 7 installation, the javac -version output is the

javac 1.7.0_80

...and the java -version gives me

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Where does this error may come from?

Dagger Note

While running the project locally I got that note.

Note: Generating a MembersInjector or Factory for com.artemzin.qualitymatters.QualityMattersApp. Prefer to run the dagger processor over that class instead.

Should we pay attention to this one?

Add SonarQube

I just read about it here and it does seem pretty neat. Unfortunately setting up might be tricky :/

Code style question

Look at code https://github.com/artem-zinnatullin/qualitymatters/blob/master/app/src/main/java/com/artemzin/qualitymatters/ui/presenters/ItemsPresenter.java#L57

Why you write items error lambda on new line? it is your code style or it has some practical sense? eg in coverage or debug?

But in other code (in your code) I do not found this style of code..

eq https://github.com/artem-zinnatullin/qualitymatters/blob/master/app/src/main/java/com/artemzin/qualitymatters/ui/fragments/ItemsFragment.java#L107

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.