Skip to main content

Posts

Showing posts with the label Robolectric

How to setup RetroLambda, Roboletric and RxAndroid together in Android Studio

Testing environment Before you proceed the process, Java 1.8 should be installed first in your system. Here is my testing system: OS: MacOSX Yosemite(Version 10.10.3) Android Studio: Version 1.2 Java SDK: Version 1.8.0_45 Project structure /Project /app /src /main /java AndroidManifest.xml /testDebug /java build.gradle /build /gradle build.gradle Configuration /Project/build.gradle Add dependencies for retrolambda and robolectric plugins under dependencies block. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.2' classpath 'me.tatarka:gradle-retrolambda:3.1.0' classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1' } } allprojects { repositories { jcenter() } } Configuration /Project/app/build.gradle apply plugin: 'co...

Robolectric setup with Android Studio

Android Studio: 1.2 1. Add class path to project build. proejct/buiild.gradle classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1' 2. Add robolectric plugin to app build. proejct/app/build.gradle project/app/build.gradle apply plugin: 'org.robolectric' 3. Add dependencies to app build. proejct/app/build.gradle dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' testCompile 'junit:junit:4.12' testCompile 'org.robolectric:robolectric:2.4' } 4. Add configurations for convenience to app build. proejct/app/build.gradle robolectric { // Configure includes / excludes include '**/*Test.class' exclude '**/espresso/**/*.class' // Configure max heap size of the test JVM maxHeapSize = '2048m' // Configure the test JVM arguments - Does not apply to Java 8 jvmArgs '-XX:MaxPermSiz...

Robolectric setup in Android Studio 1.0

These days I have been using Android Studio v1.0 and I want to do test using Robolectric, which give you more freedom for unit testing in Android. You can perform your test without emulator running. But I have faced setting problems even though the website looks like they're explaining well about how to setup the configuration. I blamed my brain but I found out there were missings for Android Studio gradle build and I had to google it a little bit more. I am not familiar with Gradle yet, but Android Studio uses Gradle as default build tool and Gradle seems to be a quite great build tool. There are two 'build.gradle's for Android Studio project. These are the main file for build configuration. One of them(a) is in your project folder is for global setting and the other one(b) in the 'app' folder is just for your app. myproject - build.gradle (a) - app - build.gradle (b) For the right setup, we need to touch a few things. 1) Installation 'Android ...