eric-hu / deckard

A simple template project for test-driven Android development using Robolectric and Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deckard

Build Status Circle CI

Deckard is the simplest possible Android application project that uses Robolectric/Espresso for testing and Gradle to build. It has one Activity, a single Robolectric test of that Activity, and an Espresso test of that Activity.

Deckard imports easily into the latest editions of Android Studio with minimal setup.

Setup

Note: These instructions assume you have a Java 1.8 JDK installed.

To start a new Android project:

  1. Install Android Studio 1.5.1.
  2. Run the Android SDK Manager and install API 23, Build-tools 23.0.2 and the support library. You can also install the packages from the terminal, using android from your sdk/tools/ directory:
android update sdk --all --no-ui --filter build-tools-23.0.2 && \
android update sdk --all --no-ui --filter android-23 && \
android update sdk --all --no-ui --filter extra-android-support && \
android update sdk --all --no-ui --filter extra-android-m2repository
  1. Download Deckard from GitHub:
wget https://github.com/robolectric/deckard/archive/master.zip
unzip master.zip
mv deckard-master my-new-project
  1. Create a local.properties file in the root of the project that points to
  2. In the project directory you should be able to run the Robolectric tests:
./gradlew clean test
  1. You should also be able to run the Espresso tests:
./gradlew clean connectedAndroidTest

Note: Make sure to start an Emulator or connect a device first so the test has something to connect to. 7. Change the names of things from 'Deckard' to whatever is appropriate for your project. Package name, classes, build.gradle, and the AndroidManifest are good places to start. 8. Build an app. Win.

Android Studio Support

Compatibility

Deckard is designed to run against Android Studio 1.5.1 with Unit Testing support enabled in Studio's Gradle settings.

Importing

Import the project into Android Studio by selecting 'Import Project' and selecting the project's build.gradle. When prompted, you can just pick the default gradle wrapper.

Running the Robolectric Test

To run Robolectric tests (example can be found in DeckardActivityTest) open Studio's "Build Variants" pane and change the "Test Artifact" to "Unit Tests". You can then run Robolectric tests using the JUnit test runner.

Running the Espresso Test

To run Espresso tests (example can be found in DeckardEspressoTest) open Studio's "Build Variants" pane and change the "Test Artifact" to "Android Instrumentation Tests". You can then run Espresso tests using the Android test runner.

About

A simple template project for test-driven Android development using Robolectric and Gradle

License:The Unlicense


Languages

Language:Java 100.0%