Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to setup unit testing in Android Studio

62,600 views

Published on

Using Robolectric and jUnit with Android Studio and Gradle

Published in: Education, Technology
  • Instead of the addTests task to get AS to recognize the java folder you can just use:

    android {
    sourceSets {
    androidTest {
    java.srcDirs = ['src/test/java']
    }
    }
    }
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Please ignore previous problem, it turns out that I've been trying this many times from behind a proxy setup and it never worked.

    When I switched to a direct connection, everything is working now. Thanks.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Keep getting this error not sure whats on, I'm using AS 0.5.3:

    Unable to resolve artifact: Missing:
    ----------
    1) org.json:json:jar:20080701

    Try downloading the file manually from the project website.

    Then, install it using the command:
    mvn install:install-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file

    Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

    Path to dependency:
    1) org.apache.maven:super-pom:pom:2.0
    2) org.json:json:jar:20080701

    ----------
    1 required artifact is missing.

    for artifact:
    org.apache.maven:super-pom:pom:2.0

    from the specified remote repositories:
    sonatype (https://oss.sonatype.org/content/groups/public/),
    central (http://repo1.maven.org/maven2)


    at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:268)
    at org.apache.maven.artifact.ant.DependenciesTask.doExecute(DependenciesTask.java:168)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
    at org.robolectric.MavenCentral.getLocalArtifactUrls(MavenCentral.java:31)
    at org.robolectric.RobolectricTestRunner.createRobolectricClassLoader(RobolectricTestRunner.java:143)
    at org.robolectric.RobolectricTestRunner.createSdkEnvironment(RobolectricTestRunner.java:116)
    at org.robolectric.RobolectricTestRunner$3.create(RobolectricTestRunner.java:279)
    at org.robolectric.EnvHolder.getSdkEnvironment(EnvHolder.java:21)
    at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:277)
    at org.robolectric.RobolectricTestRunner.access$100(RobolectricTestRunner.java:57)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:188)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:175)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException:
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

How to setup unit testing in Android Studio

  1. 1. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 http://www.flickr.com/photos/johnhaydon/5161176888/ How to setup unit testing in Android Studio Testing
  2. 2. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 What changed at the slides Changelog v.1.0.1 Removed duplicate slide v.1.0.0 Initial version
  3. 3. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 A tiny piece of structure The presentation Part 1: General project setup Part 2: IDE integration
  4. 4. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Part 1: General project setup The easy part
  5. 5. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Expecting the default project structure of Android Studio / Gradle Project structure ├── build.gradle └── app ├── build.gradle └── src └── main ├── AndroidManifest.xml ├── java └── res
  6. 6. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Robolectric and jUnit 4 to app/build.gradle Dependencies dependencies { androidTestCompile 'org.robolectric:robolectric:2.+' androidTestCompile 'junit:junit:4.+' }
  7. 7. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Add novoda/robolectric-plugin to /build.gradle Gradle plugin buildscript { repositories { mavenCentral() // Add this repository: maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' // And this dependency: classpath 'com.novoda.gradle:robolectric-plugin:0.0.1-SNAPSHOT' } } allprojects { repositories { mavenCentral() // And finally this repository again. maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } }
  8. 8. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Apply the plugin to app/build.gradle Gradle plugin apply plugin: 'robolectric' Now sync ...
  9. 9. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Create a test folder: app/src/test/java/com/example/app/test Create a test package com.example.app.test; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import static org.junit.Assert.*; @RunWith(RobolectricTestRunner.class) public class RoboTest { @Test public void testTrueIsTrue() throws Exception { assertEquals(true, true); } }
  10. 10. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Android Studio does not recognize app/src/test/java as source directory Run the test (from the shell) $ ./gradlew robolectric Should look like this … ... :app:assemble :app:compileRobolectricJava :app:processRobolectricResources UP-TO-DATE :app:robolectricClasses :app:robolectric BUILD SUCCESSFUL
  11. 11. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 The confusing part Part 2: IDE integration
  12. 12. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Add a task to app/build.gradle Register the test folder task addTest { description "Registers the test folder in the .iml file so Java tooling works." def src = ['src/test/java'] def file = file("app.iml") // Must match module file name doLast { try { def parsedXml = (new XmlParser()).parse(file) def node = parsedXml.component[1].content[0] src.each { def path = 'file://$MODULE_DIR$/' + "${it}" def set = node.find { it.@url == path } if (set == null) { new Node(node, 'sourceFolder', ['url': 'file://$MODULE_DIR$/' + "${it}", 'isTestSource': "true"]) def writer = new StringWriter() new XmlNodePrinter(new PrintWriter(writer)).print(parsedXml) file.text = writer.toString() } } } catch (FileNotFoundException e) { // nop, iml not found } } } // always do the addtest on prebuild gradle.projectsEvaluated { preBuild.dependsOn(addTest) }
  13. 13. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 The test folder is recognized by Android Studio Register the test folder
  14. 14. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Pick it from the context menu ... Run All Tests
  15. 15. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Test were not started Failed to run tests !!! JUnit version 3.8 or later expected: java.lang.RuntimeException: Stub! at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5) at junit.textui.TestRunner.<init>(TestRunner.java:54) at junit.textui.TestRunner.<init>(TestRunner.java:48) at junit.textui.TestRunner.<init>(TestRunner.java:41) Process finished with exit code 253 Copy everything printed to the output!
  16. 16. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Before ... Some text editor work /usr/lib/jvm/jdk1.7.0/bin/java -ea -Didea.launcher.port=7532 -Didea.launcher.bin.path=/opt/android-studio/bin -Dfile.encoding=UTF-8 -classpath /opt/android-studio/lib/idea_rt.jar:/opt/android-studio/plugins/junit/lib/junit-rt.jar:/media/data/SDKs/android-sdk-linux_x86/platforms/android-19/android.jar:/ media/data/SDKs/android-sdk-linux_x86/platforms/android-19/data/res:/media/data/SDKs/android-sdk-linux_x86/tools/support/annotations.jar:/media/data/Development _Ubuntu/TestRobolectricHome/app/build/classes/debug:/home/tobias/.gradle/caches/modules-2/files-2.1/classworlds/classworlds/1.1-alpha-2/5adf2e681c57d7f48038b602 f3ca2254ee82d47/classworlds-1.1-alpha-2.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.codehaus.plexus/plexus-utils/1.5.15/c689598ce1eb94c304817877ed15 911099972526/plexus-utils-1.5.15.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.objenesis/objenesis/1.3/dc13ae4faca6df981fc7aeb5a522d9db446d5d50/objene sis-1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact-manager/2.2.1/ec355b913c34d37080810f98e3f51abecbe1572b/maven-artifac t-manager-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/nekohtml/nekohtml/1.9.6.2/2d960be7b62ae6622dbbbe49ab4ffdc609f85c80/nekohtml-1.9.6.2.jar:/hom e/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/4.1/51085abcc4cb6c6e1cb5551e6f999eb8e31c5b2d/asm-tree-4.1.jar:/home/tobias/.gradle/caches/modul es-2/files-2.1/org.ow2.asm/asm/4.1/ad568238ee36a820bd6c6806807e8a14ea34684d/asm-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.xerial/sqlite-jdbc/3 .7.2/7a3d67f00508d3881650579f7f228c61bfc1b196/sqlite-jdbc-3.7.2.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.0/7b456ca6b93900f96e5 8cc8371f03d90a9c1c8d1/ant-1.8.0.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-repository-metadata/2.2.1/98f0c07fcf1eeb213bef8d9316a 9935184084b06/maven-repository-metadata-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-ant-tasks/2.1.3/b09be554228d66d208e5fef 5266844aacf443abc/maven-ant-tasks-2.1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-error-diagnostics/2.2.1/e81bb342d7d172f23d108 dc8fa979a1facdcde8e/maven-error-diagnostics-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-http-lightweight/1.0-beta-6/b 3815078570c3b1f0667e123d59717c6b726c6c2/wagon-http-lightweight-1.0-beta-6.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd 32786786e2adb664d5ecc965da47629dca14ba/commons-codec-1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-http-shared/1.0-beta-6 /ccd70d7e0d8c085e648a83f072da06ca9a53be94/wagon-http-shared-1.0-beta-6.jar:/media/data/Development_Ubuntu/TestRobolectricHome/app/build/exploded-aar/com.android .support/appcompat-v7/19.0.1/res:/media/data/Development_Ubuntu/TestRobolectricHome/app/build/exploded-aar/com.android.support/appcompat-v7/19.0.1/classes.jar:/ home/tobias/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/2.2/af902024b55e3b41732a7d9f41c32f90c065be2f/robolectric-2.2.jar:/home/tobias/.gradle /caches/modules-2/files-2.1/org.codehaus.plexus/plexus-container-default/1.0-alpha-9-stable-1/94aea3010e250a334d9dab7f591114cd6c767458/plexus-container-default- 1.0-alpha-9-stable-1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/backport-util-concurrent/backport-util-concurrent/3.1/682f7ac17fed79e92f8e87d8455192b63 376347b/backport-util-concurrent-3.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-plugin-registry/2.2.1/72a24b7775649af78f3986b5aa 7eb354b9674cfd/maven-plugin-registry-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-settings/2.2.1/2236ffe71fa5f78ce42b0f5fc22 c54ed45f14294/maven-settings-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-file/1.0-beta-6/6c53633505460caf49d2660de1e2 4744d915afb9/wagon-file-1.0-beta-6.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/com.ximpleware/vtd-xml/2.11/ee5bcf62c1acf76434ee9f1c67a840bafef72a6d/vtd- xml-2.11.jar:/media/data/SDKs/android-sdk-linux_x86/extras/android/m2repository/com/android/support/support-v4/19.0.1/support-v4-19.0.1.jar:/home/tobias/.gradle /caches/modules-2/files-2.1/org.ow2.asm/asm-commons/4.1/f8b86f4ee6e02082f63a658e00eb5506821253c6/asm-commons-4.1.jar:/home/tobias/.gradle/caches/modules-2/files -2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/a sm-analysis/4.1/73401033069e4714f57b60aeae02f97210aaa64e/asm-analysis-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069a eb2bffb4019e7a5034a4ee0/junit-4.11.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact/2.2.1/23600f790d4dab2cb965419eaa982e3e84c 428f8/maven-artifact-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-profile/2.2.1/3950071587027e5086e9c395574a60650c432738/mav en-profile-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/com.google.android/support-v4/r7/24d0f6da34c3a2bfcf736ab42d51c91ac821ee22/support-v4-r7.jar :/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/4.1/6344065cb0f94e2b930a95e6656e040ebc11df08/asm-util-4.1.jar:/home/tobias/.gradle/caches/ modules-2/files-2.1/org.apache.maven/maven-model/2.2.1/c0a1c17436ec3ff5a56207c031d82277b4250a29/maven-model-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/file s-2.1/org.easytesting/fest-util/1.2.5/c4a8d7305b23b8d043be12c979813b096df11f44/fest-util-1.2.5.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.an t/ant-launcher/1.8.0/8b53ba16fa62fb1034da8f1de200ddc407c8381/ant-launcher-1.8.0.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.codehaus.plexus/plexus-i nterpolation/1.11/ad9dddff6043194904ad1d2c00ff1d003c3915f7/plexus-interpolation-1.11.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.easytesting/fest-re flect/1.4.1/2b92d5275e92a49e16c7ce6bd7e46b9080db0530/fest-reflect-1.4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-project/2.2.1 /8239e98c16f641d55a4ad0e0bab0aee3aff8933f/maven-project-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-provider-api/1.0- beta-6/3f952e0282ae77ae59851d96bb18015e520b6208/wagon-provider-api-1.0-beta-6.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/nekohtml/xercesMinimal/1.9.6.2 /d1c5e063683a0e6f77cd5f051a9d4af48346fa6/xercesMinimal-1.9.6.2.jar ... Remove everything before -classpath Find juni part and prepend it
  17. 17. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 After ... Some text editor work -classpath /home/tobias/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar:/opt/android-studio/lib/idea_rt.jar:/op t/android-studio/plugins/junit/lib/junit-rt.jar:/media/data/SDKs/android-sdk-linux_x86/platforms/android-19/android.jar:/media/data/SDKs/android-sdk-linux_x86/p latforms/android-19/data/res:/media/data/SDKs/android-sdk-linux_x86/tools/support/annotations.jar:/media/data/Development_Ubuntu/TestRobolectricHome/app/build/c lasses/debug:/home/tobias/.gradle/caches/modules-2/files-2.1/classworlds/classworlds/1.1-alpha-2/5adf2e681c57d7f48038b602f3ca2254ee82d47/classworlds-1.1-alpha-2 .jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.codehaus.plexus/plexus-utils/1.5.15/c689598ce1eb94c304817877ed15911099972526/plexus-utils-1.5.15.jar:/h ome/tobias/.gradle/caches/modules-2/files-2.1/org.objenesis/objenesis/1.3/dc13ae4faca6df981fc7aeb5a522d9db446d5d50/objenesis-1.3.jar:/home/tobias/.gradle/caches /modules-2/files-2.1/org.apache.maven/maven-artifact-manager/2.2.1/ec355b913c34d37080810f98e3f51abecbe1572b/maven-artifact-manager-2.2.1.jar:/home/tobias/.gradl e/caches/modules-2/files-2.1/nekohtml/nekohtml/1.9.6.2/2d960be7b62ae6622dbbbe49ab4ffdc609f85c80/nekohtml-1.9.6.2.jar:/home/tobias/.gradle/caches/modules-2/files -2.1/org.ow2.asm/asm-tree/4.1/51085abcc4cb6c6e1cb5551e6f999eb8e31c5b2d/asm-tree-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/4.1/ad56 8238ee36a820bd6c6806807e8a14ea34684d/asm-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.xerial/sqlite-jdbc/3.7.2/7a3d67f00508d3881650579f7f228c61bf c1b196/sqlite-jdbc-3.7.2.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.0/7b456ca6b93900f96e58cc8371f03d90a9c1c8d1/ant-1.8.0.jar:/ho me/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-repository-metadata/2.2.1/98f0c07fcf1eeb213bef8d9316a9935184084b06/maven-repository-metadata -2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-ant-tasks/2.1.3/b09be554228d66d208e5fef5266844aacf443abc/maven-ant-tasks-2.1.3 .jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-error-diagnostics/2.2.1/e81bb342d7d172f23d108dc8fa979a1facdcde8e/maven-error-diagnos tics-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-http-lightweight/1.0-beta-6/b3815078570c3b1f0667e123d59717c6b726c6c2 /wagon-http-lightweight-1.0-beta-6.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba/ commons-codec-1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-http-shared/1.0-beta-6/ccd70d7e0d8c085e648a83f072da06ca9a53be 94/wagon-http-shared-1.0-beta-6.jar:/media/data/Development_Ubuntu/TestRobolectricHome/app/build/exploded-aar/com.android.support/appcompat-v7/19.0.1/res:/media /data/Development_Ubuntu/TestRobolectricHome/app/build/exploded-aar/com.android.support/appcompat-v7/19.0.1/classes.jar:/home/tobias/.gradle/caches/modules-2/fi les-2.1/org.robolectric/robolectric/2.2/af902024b55e3b41732a7d9f41c32f90c065be2f/robolectric-2.2.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.codehau s.plexus/plexus-container-default/1.0-alpha-9-stable-1/94aea3010e250a334d9dab7f591114cd6c767458/plexus-container-default-1.0-alpha-9-stable-1.jar:/home/tobias/. gradle/caches/modules-2/files-2.1/backport-util-concurrent/backport-util-concurrent/3.1/682f7ac17fed79e92f8e87d8455192b63376347b/backport-util-concurrent-3.1.ja r:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-plugin-registry/2.2.1/72a24b7775649af78f3986b5aa7eb354b9674cfd/maven-plugin-registry-2. 2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-settings/2.2.1/2236ffe71fa5f78ce42b0f5fc22c54ed45f14294/maven-settings-2.2.1.jar: /home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-file/1.0-beta-6/6c53633505460caf49d2660de1e24744d915afb9/wagon-file-1.0-beta-6.jar: /home/tobias/.gradle/caches/modules-2/files-2.1/com.ximpleware/vtd-xml/2.11/ee5bcf62c1acf76434ee9f1c67a840bafef72a6d/vtd-xml-2.11.jar:/media/data/SDKs/android-s dk-linux_x86/extras/android/m2repository/com/android/support/support-v4/19.0.1/support-v4-19.0.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm /asm-commons/4.1/f8b86f4ee6e02082f63a658e00eb5506821253c6/asm-commons-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a 25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/4.1/73401033069e4714f57b60a eae02f97210aaa64e/asm-analysis-4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact/2.2.1/23600f790d4dab2cb965419eaa982e3e84c 428f8/maven-artifact-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-profile/2.2.1/3950071587027e5086e9c395574a60650c432738/mav en-profile-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/com.google.android/support-v4/r7/24d0f6da34c3a2bfcf736ab42d51c91ac821ee22/support-v4-r7.jar :/home/tobias/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/4.1/6344065cb0f94e2b930a95e6656e040ebc11df08/asm-util-4.1.jar:/home/tobias/.gradle/caches/ modules-2/files-2.1/org.apache.maven/maven-model/2.2.1/c0a1c17436ec3ff5a56207c031d82277b4250a29/maven-model-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/file s-2.1/org.easytesting/fest-util/1.2.5/c4a8d7305b23b8d043be12c979813b096df11f44/fest-util-1.2.5.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.an t/ant-launcher/1.8.0/8b53ba16fa62fb1034da8f1de200ddc407c8381/ant-launcher-1.8.0.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.codehaus.plexus/plexus-i nterpolation/1.11/ad9dddff6043194904ad1d2c00ff1d003c3915f7/plexus-interpolation-1.11.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.easytesting/fest-re flect/1.4.1/2b92d5275e92a49e16c7ce6bd7e46b9080db0530/fest-reflect-1.4.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-project/2.2.1 /8239e98c16f641d55a4ad0e0bab0aee3aff8933f/maven-project-2.2.1.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/org.apache.maven.wagon/wagon-provider-api/1.0- beta-6/3f952e0282ae77ae59851d96bb18015e520b6208/wagon-provider-api-1.0-beta-6.jar:/home/tobias/.gradle/caches/modules-2/files-2.1/nekohtml/xercesMinimal/1.9.6.2 /d1c5e063683a0e6f77cd5f051a9d4af48346fa6/xercesMinimal-1.9.6.2.jar ... The juni part is at the beginning now
  18. 18. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Classpath goes into VM options Setup run configuration
  19. 19. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Create a Gradle task Generate Robolectric classes
  20. 20. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Add to JUnit configuration, Before launch Launch Robolectric configuration
  21. 21. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 Big thanks to Ilkka Laukkanen Credits Further information: http://blog.futurice.com/android_unit_testing_in_ides_and_ci_environments
  22. 22. Tobias Preuss – 26.03.2014 – GDG Android in Berlin – v.1.0.1 http://www.flickr.com/photos/dopey/123646856/ Questions

×