From ccf0fa07662846749c569b51b76b01476736193e Mon Sep 17 00:00:00 2001 From: Erich Douglass Date: Thu, 31 Jul 2014 11:46:50 -0700 Subject: [PATCH] Move non-essential sections of the README to the wiki. --- README.md | 59 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index eef642b..729d624 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A Gradle plugin which enables Robolectric tests. ## Compatibility -Currently known to work with Gradle 1.11, Android Gradle Plugin 0.11.x, Android Studio 0.6.x, and IntelliJ IDEA 13. +Currently compatible with version 0.11.x of the android gradle plugin. ## Getting Started @@ -28,13 +28,10 @@ apply plugin: 'robolectric' Add test-only dependencies using the `androidTestCompile` configuration: ```groovy -androidTestCompile 'junit:junit:4.10' androidTestCompile 'org.robolectric:robolectric:2.3.+' -androidTestCompile 'com.squareup:fest-android:1.0.+' ``` -Write your tests in `src/test/java/`! You can also add per-build type and per-flavor tests by using -the same folder naming conventions (e.g., `src/testPaid/java/`, `src/testDebug/java/`). +Place your tests in `src/test/java` or `src/androidTest/java` You can also add per-build type and per-flavor tests by using the same folder naming conventions (e.g., `src/testPaid/java`, `src/testDebug/java`). Run your tests by calling `gradle clean test`. @@ -70,58 +67,6 @@ It bears repeating, though: if you see the dreaded `Stub!` exception: ...you will have to hand-edit your dependencies (in the IDE for IntelliJ, or hand-editing your IML file in Studio). See [deckard-gradle](https://github.com/robolectric/deckard-gradle) for details. -## Robolectric 2.2 or earlier - -Version 2.3 of Robolectric will support this plugin out of the box ([see here](https://github.com/robolectric/robolectric/pull/744)). -Until then, you can use the following test runner: -```java -import org.junit.runners.model.InitializationError; -import org.robolectric.AndroidManifest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.res.Fs; - -public class RobolectricGradleTestRunner extends RobolectricTestRunner { - public RobolectricGradleTestRunner(Class testClass) throws InitializationError { - super(testClass); - } - - @Override protected AndroidManifest getAppManifest(Config config) { - String manifestProperty = System.getProperty("android.manifest"); - if (config.manifest().equals(Config.DEFAULT) && manifestProperty != null) { - String resProperty = System.getProperty("android.resources"); - String assetsProperty = System.getProperty("android.assets"); - return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty), - Fs.fileFromPath(assetsProperty)); - } - return super.getAppManifest(config); - } -} -``` - -Just annotate your test classes with `@RunWith(RobolectricGradleTestRunner.class)` or subclass this -test runner if you have other customizations. - -## Plugin Development - -The `example/` dir contains a project which covers a few configurations for the plugin to work with. - - 1. Run `./gradlew install` in the root. This will build the plugin and install it into a local Maven - repository. - 2. In the `example/` folder, run `../gradlew clean check` to build and run the unit tests. - 3. Open `example/build/test-report/index.html` in the browser. - -### Debugging - -You can run the plugin in the debugger, but it takes some setup. - -1. Execute this at the root of your project: - ``` - GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006" ./gradlew test --no-daemon -Dorg.gradle.debug=true - ``` -2. Point a remote debugger to port 5006. In Intellij set up 'Remote' Debug configuration and set the port (actual port can be changed) -3. In IntelliJ, to break at breakpoints inside of our plugin or other gradle code you will need to put the appropriate JARs on your classpath, and then attach the source. It's a bit of a hack but it is possible in IntelliJ, anyway :). - ## License Copyright 2013 Square, Inc.