twocity / AndroidStudioAndRobolectric

Minimal Robolectric and Android Studio example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AndroidStudioAndRobolectric

  • Android Studio 1.1 Overview (works also with 1.2 preview 3)
  • Android Gradle Build Tools 1.1.3 Overview
  • Gradle 2.3 Overview
  • Robolectric 3.0-SNAPSHOT (works much much better with Android SDK v21 than older releases)
  • no extra plugins necessary (but you should also try robolectric-gradle-plugin)

For details see http://nenick-android.blogspot.de/2015/03/android-studio-110-and-robolectric-30.html

Get Started on command-line

  1. Just clone.
  2. Go into the project directory.
  3. Run ./gradlew test and get started with robolectric.

Get Started with Android Studio

  1. Import this project with Android Studio.
  2. Change the Build Variant // Test Artifact to Unit Test (http://tools.android.com/tech-docs/unit-testing-support).
  3. Right click on a test and get started with robolectric.

More example project setups

Flavors

Here an example with flavors https://github.com/nenick/AndroidStudioAndRobolectric/tree/flavors

Multi Modules (Android Library)

Here an example with android library module https://github.com/nenick/AndroidStudioAndRobolectric/tree/library

Separate Test Module

For some use cases it is great to split tests into different modules https://github.com/nenick/android-gradle-template

About

Minimal Robolectric and Android Studio example


Languages

Language:Java 100.0%