Combines tools for fast android app devlopment

Overview

Android - Rapid Test Driven Development

  • Combine tools to generate most of the boilerplate code.
  • Examples how to test different aspects of an android application.
  • Clean architecture approach with MVP and package by feature.

For details see Project Documentations

Wishes, improvements, questions and discussions about the stuff here are welcome.

Circle CI Coverage Status

Last successful tests with

  • Android Studio 1.3.2
  • Gradle Build Tools 1.3.0
  • Gradle 2.6
  • Android v22
  • Java 8

Getting Started

Import the project into Android Studio and start developing. For more details see Getting Started

Comments
  • Espresso tests - could they be placed outside the app src folder?

    Espresso tests - could they be placed outside the app src folder?

    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.

    wish 
    opened by RichardGuion 13
  • 'android' or 'android-library' plugin is required

    'android' or 'android-library' plugin is required

    I have been using android-gradle-template for my project for a while. Since updating to Android Studio 0.8.9 I get this error after opening the AppUnitTests/build.gradle file and then running the test runner:

    Error:(19, 0) Gradle: A problem occurred evaluating project ':AppUnitTests'.

    The 'android' or 'android-library' plugin is required.

    This happens after building the testClasses just before the tests start running. Do you know what could be causing it?

    opened by DylanSale 8
  • FileNotFound Exception

    FileNotFound Exception

    Hi,

    I'm trying to make my Robolectric tests work with Jacoco support, but it seems that the plugin is not compatible with Dagger as it can not find some class files with '$$' in the filename. For this reason I got a FileNotFoundException when executing the 'jacocoTestReport' task. Is this related to the 'known issue' on this page: http://tools.android.com/tech-docs/new-build-system or is this something that needs to be fixed in Dagger, Android build tools or the Jacoco plugin?

    Thanks.

    opened by josomers 8
  • jacoco with espresso, task jacocoTestReport skipped

    jacoco with espresso, task jacocoTestReport skipped

    i use the solution in my project with espresso , task skipped. my build.gralde

    apply plugin: 'jacoco'
    
    android {
      buildTypes {
        debug {
          testCoverageEnabled true
        }
      }
      jacoco {
        version "0.7.1.201405082137"
      }
    
    
    def coverageSourceDirs = [
            'src/main/java',
    ]
    
    task jacocoTestReport(type: JacocoReport) {
        group = "Reporting"
        description = "Generate Jacoco coverage reports after running tests."
        reports {
            xml.enabled = true
            html.enabled = true
        }
        classDirectories = fileTree(
                dir: './build/intermediates/classes/debug',
                excludes: ['**/R*.class',
                           '**/*$InjectAdapter.class',
                           '**/*$ModuleAdapter.class',
                           '**/*$ViewInjector*.class'
                ])
        sourceDirectories = files(coverageSourceDirs)
        executionData = files("$buildDir/jacoco/testDebug.exec")
    
        doFirst {
            new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
                if (file.name.contains('$$')) {
                    file.renameTo(file.path.replace('$$', '$'))
                }
            }
        }
    }
    

    result:

    ./gradlew  jacocoTestReport --stacktrace
    setup
    create beta
    cleanPublish:/home/sunhao/Project/android/build/apks
    :app:jacocoTestReport SKIPPED
    
    BUILD SUCCESSFUL
    
    opened by sunhao111999 6
  • A problem occurred evaluating project ':ComponentTestsRobolectric'

    A problem occurred evaluating project ':ComponentTestsRobolectric'

    Hey there,

    Thanks a lot for sharing. Recently I've upgraded my Android Studio to the latest version (0.8.2) and today I've noticed your project on github. Unfortunately tests don't pass when I run them from script and I am given this error:

    A problem occurred evaluating project ':ComponentTestsRobolectric'.

    (class: com/novoda/gradle/test/SupportedLanguages, method: super$1$stream signature: ()Ljava/util/stream/Stream;) Illegal use of nonvirtual function call.

    Particularily, it complains in this line:

    android { projectUnderTest ':AndroidSample' }

    Primarily I thought it was connected with java version but it's not.

    Is this the Android Studio version issue? Is anyone familiar with this error? If so, how to get it working?

    Thanks, Dawid

    opened by dawidgdanski 6
  • Voting: Which is your favourite way to support robolectric?

    Voting: Which is your favourite way to support robolectric?

    I'm very thankful that the novoda team created a great plugin to support robolectric. I used this plugin for about one year now. The main advantage was the good support for robolectric + espresso where other plugins had some issues. But I disliked that there was not much support. It's looked like they dropped the support. But since short time they are much more active.

    The plugin from JCAndKSolutions has the same support like the novoda plugin, but much better integration with android studio when you install the android studio plugin.

    Now i think about to drop the novoda example. Would someone dislike this decision? Please tell me also short why.

    opened by nenick 5
  • Unable to import project

    Unable to import project

    1. fresh clone
    2. I click "Import Project..." from the "Welcome to Android Studio" window.
    3. Select the build.gradle on the root folder
    4. I get the following error Error:(17, 0) (class: com/novoda/gradle/test/SupportedLanguages, method: super$1$stream signature: ()Ljava/util/stream/Stream;) Illegal use of nonvirtual function call

    I am not sure if I'm missing something, I also tried

    1. fresh clone
    2. I ran Script/install-custom-gradle-test-plugin.sh from android-gradle-template folder
    3. I click "Import Project..." from the "Welcome to Android Studio" window.
    4. Select the build.gradle on the root folder
    5. I get the same error

    I also tried

    1. fresh clone
    2. I ran install-custom-gradle-test-plugin.sh from android-gradle-template/Script folder
    3. I click "Import Project..." from the "Welcome to Android Studio" window.
    4. Select the build.gradle on the root folder
    5. I get the same error
    opened by daveenguyen 5
  • Error Illegal use of non virtual function call

    Error Illegal use of non virtual function call

    Hi, Thanks a lot for this template, I'm trying to apply the same structure to my project everything worked fine except in my unit test module i got : Error:(20, 0) (class: com/novoda/gradle/test/SupportedLanguages, method: super$1$stream signature: ()Ljava/util/stream/Stream;) Illegal use of nonvirtual function call

    I added : compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } to my app module thinking maybe it's because of java version but that didn't work. should i launch the install script install-custom-gradle-test-plugin.sh and use android-studio-robolectric-support.gradle with a specific java version ?

    thanks.

    opened by chemouna 4
  • Trying to copy your pattern

    Trying to copy your pattern

    Hi - trying to follow your pattern of sub directories with an existing project. I have tried to replicate what you have almost exactly. Yet when I build I get this error:

    • What went wrong: A problem occurred evaluating project ':UnitTestsRobolectric'.

      The 'android' or 'android-library' plugin is required.

    It thinks that the main Android application doesn't have the android plugin applied, yet it does! Any idea what I am doing wrong?

    The directory structure looks like:

    android
       build.gradle
       settings.gradle
       app/
           build.gradle
       UnitTestsRobolectric
           build.gradle
    

    Settings.gradle:

      include ':app', 'UnitTestsRobolectric'
    

    My build.gradle in the top most folder has the same settings as yours, except I use build tools 19.0.1.

    app/build.gradle has this at top:

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:0.10.+'
        }
    }
    
    apply plugin: 'android'
    ...
    

    UnitTestsRobolectric/build.gradle has this:

    buildscript {
        repositories {
          maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.10.+'
            classpath "com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT"
            classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.4.0'
        }
    }
    
    apply plugin: 'java'
    
    test.reports.html.enabled = false     // just clean up dashboard from not generated reports
    test.reports.junitXml.enabled = false // just clean up dashboard from not generated reports
    
    apply plugin: 'android-test'
    apply plugin: "jacoco"
    apply plugin: 'coveralls'
    apply plugin: 'idea'
    
    repositories {
      maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    }
    
    android {
      projectUnderTest ':app'
    }
    

    I see this code in the plugin source so I know it must have found the gradle file for the app, but I can't explain why it doesn't see the android plugin applied!

    public void projectUnderTest(String projectName) {
    
        Project projectUnderTest = project.project(projectName)
    
        def hasAppPlugin = hasAppPlugin(projectUnderTest)
        def hasLibraryPlugin = hasLibraryPlugin(projectUnderTest)
    
        if (!hasAppPlugin && !hasLibraryPlugin) {
            throw new IllegalStateException("The 'android' or 'android-library' plugin is required.")
    
    pitfall 
    opened by RichardGuion 4
  • Errors in tests

    Errors in tests

    Just curious, I see some errors when I run the tests currently. Is that intentional, to show us how errors will look in the reports?

    Example: gradlew :UnitTestsRobolectric:testDebug

    :UnitTestsRobolectric:testDebug

    com.example.activities.DatabaseActivityTest > test_shouldResetAllInputFields FAILED java.lang.UnsupportedClassVersionError at DatabaseActivityTest.java:64

    pitfall 
    opened by RichardGuion 4
  • When using this template, I've faced some problems

    When using this template, I've faced some problems

    Problem #1: this bug stops me from working:

    https://github.com/novoda/gradle-android-test-plugin/issues/10

    Problem #2:

    In the UnitTestsRobolectric/build.gradle, I've had to change this line:

    classpath "com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT"
    

    to this other:

    classpath "com.novoda:gradle-android-test-plugin:0.9.3-SNAPSHOT"
    

    Otherwise, Gradle cannot download the version.

    opened by DavidPerezIngeniero 3
  • Android Studio 1.4 Java modules cannot depend on Android modules

    Android Studio 1.4 Java modules cannot depend on Android modules

    With Android Studio 1.4 the component tests (appCt) can't resolve the app classes anymore.

    Follow https://code.google.com/p/android/issues/detail?id=188880 for updates to this issue.

    opened by nenick 0
Owner
Nico Küchler
Nico Küchler
A tool to install components of the Android SDK into a Maven repository or repository manager to use with the Android Maven Plugin, Gradle and other tools.

Maven Android SDK Deployer Original author including numerous fixes and changes: Manfred Moser [email protected] at simpligility technologies i

simpligility 1.4k Dec 27, 2022
🍼Debug Bottle is an Android runtime debug / develop tools written using kotlin language.

???? 中文 / ???? 日本語 / ???? English ?? Debug Bottle An Android debug / develop tools written using Kotlin language. All the features in Debug bottle are

Yuriel Arlencloyn 846 Nov 14, 2022
A set of Android tools that facilitate apps development

A set of Android tools that facilitate apps development Well, this repo contains pretty much code used internally at Stanfy to develop Android apps. S

Stanfy 183 Dec 3, 2022
Analytics Tools for Kotlin Multiplatform Mobile iOS and android

Index Features Example Introduce Architecture Installation Configure Using Screen Mapper Initialization Implementation Delegate Parameters ATEventPara

LINE 16 Dec 5, 2022
A super fast build tool for Android, an alternative to Instant Run

Freeline Freeline is a super fast build tool for Android and an alternative to Instant Run. Caching reusable class files and resource indices, it enab

Alibaba 5.5k Jan 2, 2023
Automated-build-android-app-with-github-action - CI/CD Automated Build Android App Bundle / APK / Signed With Github Action

Automated Build Android With Using Github Action Project Github Action Script Us

Faisal Amir 34 Dec 19, 2022
This Android app adds splash screen slides to make a great intro for an app.

IntroApp This Android app adds splash screen slides to make a great intro for an app. Short description Adding Welcome / Intro screens in your app is

Vaibhav Khulbe 16 Oct 1, 2020
A simple utility to remove unused resources in your Android app to lower the size of the APK. It's based on the Android lint tool output.

android-resource-remover android-resource-remover is utility that removes unused resources reported by Android Lint from your project. The goal is to

Keepsafe 1.3k Dec 16, 2022
This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically.

#Android Localizationer This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically. T

Wesley Lin 822 Dec 8, 2022
An android library that handles the closing of your app interactively.

Shutdown A library that handles the closing of your app interactively. Overview of Shutdown library Shutdown library handles the closing of your app i

Emmanuel Kehinde 56 Oct 5, 2022
Android Resource Manager application to manage and analysis your app resources with many features like image resize, Color, Dimens and code Analysis

Android Resource Manager application to manage and analysis your app resources with many features like image resize, Color, Dimens and code Analysis

Amr Hesham 26 Nov 16, 2022
A surgical debugging tool to uncover the layers under your app.

Scalpel DEPRECATED! Android Studio 4.0's layout inspector now includes a live-updating 3D view. Use it! A surgical debugging tool to uncover the layer

Jake Wharton 2.8k Jan 3, 2023
proguard resource for Android by wechat team

AndResGuard Read this in other languages: English, 简体中文. AndResGuard is a tooling for reducing your apk size, it works like the ProGuard for Java sour

shwenzhang 8.1k Jan 9, 2023
Command-line tool to count per-package methods in Android .dex files

dex-method-counts Simple tool to output per-package method counts in an Android DEX executable grouped by package, to aid in getting under the 65,536

Mihai Parparita 2.6k Nov 25, 2022
View Inspection Toolbar for Android Development

View Inspector Plugin View inspection toolbar for android development. Features Boundary show outlines show margins show paddings Layer Scalpel featur

Fumihiro Xue (Peter Hsieh) 2.2k Nov 14, 2022
Make Android screenshots of scrollable screen content

scrollscreenshot Make Android screenshots of scrollable screen content - brought to you by PGS Software SA This tool makes a number of screenshots, sc

PGS Software 714 Dec 7, 2022
[] Dissect layout traversals on Android

Probe Dissect layout traversals on Android. Features Intercept View methods. onMeasure(int, int) onLayout(boolean, int, int, int, int) draw(Canvas) an

Lucas Rocha 555 Nov 25, 2022
Android Library Finder

alfi Android Library Finder Search through thousands of android libraries that can help you scale your projects elegantly Usage Search for something a

César Ferreira 509 Dec 8, 2022