[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.

Overview

#[Deprecated] Google has finally released a proper solution for unit testing. Therefore this plugin will no longer be activlty maintained.

android-studio-unit-test-plugin

Android Studio (and Intellij 14) IDE support for Android gradle unit tests.

This plugin will mark test directories and resolve testCompile dependencies. It also sets up the correct system properties so that Robolectric will work if you are using it.

alt tag

Requirements

  • Android Studio 0.6.0+
  • Android Gradle Plugin 0.11.0+
  • JCAndKSolutions' android-unit-test gradle plugin 1.5.0+

Install IDE the plugin

In Android Studio go to Settings -> Plugins -> Browse Repositories... and search for 'Android Studio Unit Test'.

If you feel like living on the edge, can download the zip then go to Settings -> Plugins -> Install plugin from disk.. to install.

Install the gradle plugin

To add unit testing support to your gradle project, you need JCAndKSolutions' android-unit-test gradle plugin. You need to set it up as described in the README. Make sure you have at least version 1.5.0.

Troubleshooting

  • Running tests from the IDE gives a ClassNotFoundException or something similar.

If you are running Android Stuido 0.8.9+. The latest version of this plugin will compile your test classes before running the test. However, the very first time you run them after they have been cleaned, you will still get this error. Simply attempting to run again will fix it and any subsiquent runs will work correctly.

If you are running intellij or and older version of Android Studio. If your app includes a library project compile project(":myLib") then the JUnit test runner will attempt to run testClasses on that project. Since it doesn't have that task it will fail and your test classes will not be generated. To fix, add the needed task to your library project.

task testClasses {}
  • The relative path for Robolectric's @Config(manifest = "path") is different between gradle and Android Studio.

    This is because when creating a run configuration, the path is by default relative to your project root, whereas when running it from gradle it's correctly relative to your apps root. To fix, edit the JUnit run configuration and change Working Directory to point to your app root.

Comments
  • Javadoc and Sources for dependencies

    Javadoc and Sources for dependencies

    I'm not sure if there is anything you can do about this, specially since it is something that I think not even the android plugin does, but I really hate that IntelliJ IDEA is perfectly capable of using sources and Javadoc but since the gradle plugin doesn't populate the fields for it, it won't load up except for the android.jar.

    I know the android gradle plugin and your plugin modify the .iml file to add the dependencies and probably also create the dependency.xml inside .idea\libraries\ folder. The thing is that this XMLs are only like this:

    <component name="libraryTable">
      <library name="support-v4-20.0.0">
        <CLASSES>
          <root url="jar://$PROJECT_DIR$/common/commonAndroid/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar!/" />
          <root url="file://$PROJECT_DIR$/common/commonAndroid/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/res" />
          <root url="jar://$PROJECT_DIR$/common/commonAndroid/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/libs/internal_impl-20.0.0.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES />
      </library>
    </component>
    

    As you can see the JAVADOC and SOURCES tags are empty. If only this XML could get added the sources and/or javadoc, it would be awesome. I know your plugin is only in charge of the test dependencies but maybe just until AS can do this on its own, it would be nice if all the dependencies could get the javadoc and/or sources and not only the test ones.

    I do understand though that gradle might not have downloaded the sources and javadoc and just the .jar since the compilation doesn't need it, but in my case I used mvn directy to download them so I know that they exist in my \.m2\ cache.

    What are your thoughts?

    enhancement 
    opened by SuperJugy 21
  • Test classes not found in Intellij 14 EAP

    Test classes not found in Intellij 14 EAP

    It looks like the test classes are not on the classpath when running the tests in the IDE. I am using the Android gradle plugin version 0.12.1 And Android unit test plugin 1.2.2 Intellij 14 EAP IC-138.777

    bug 
    opened by jtietema 17
  • doesn't work with android studio rc2 anymore

    doesn't work with android studio rc2 anymore

    The plugin worked nicely in android studio rc1. Today after the upgrade to rc2 it doesn't work anymore. A colleague could confirm that it doesn't work in rc2.

    Thanks for this plugin!

    bug 
    opened by fgutmann 15
  • No junit.jar

    No junit.jar

    Trying out the plugin with AS 0.8.1 and JCandK's android-test-plugin 1.2.2. When I create a new configuration, it tells me already with red letters Module not specified.

    Now when I try to run a test, I receive

    23:43:28 Error running MyTest: No junit.jar

    opened by realdadfish 13
  • Inner module isn't handled

    Inner module isn't handled

    Scope

    Simple project with sample and library structure: --Project ----Sample ----Library

    Problem

    Library has robolectric tests and terminal command works well ./gradlew clean library:test. But in AS test folder is not recognized but plugin, as well as dependencies starting with testCompile.

    In AS RC1 log shows the problem (but RC 2 doesn't show it anymore):

    INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS) 
    2014-12-02 01:39:47,736 [1279662]   INFO - dea.AndroidUnitTestDataService - Failed to set up Android modules in project 'android-validation-komensky' 
    java.lang.NullPointerException
      at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:37)
      at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:23)
      at me.tatarka.androidunittest.idea.AbstractContentRootModuleCustomizer.customizeModule(AbstractContentRootModuleCustomizer.java:51)
      at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.customizeModule(AndroidUnitTestDataService.java:82)
      at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.access$100(AndroidUnitTestDataService.java:26)
      at me.tatarka.androidunittest.idea.AndroidUnitTestDataService$1.execute(AndroidUnitTestDataService.java:73)
      at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364)
      at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:374)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359)
      at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.doImport(AndroidUnitTestDataService.java:66)
      at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.importData(AndroidUnitTestDataService.java:48)
      at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:90)
      at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:74)
      at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:98)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1$1.run(ProjectSetUpTask.java:117)
      at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:329)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1.execute(ProjectSetUpTask.java:112)
      at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364)
      at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361)
      at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:381)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359)
      at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:355)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask$2.run(ProjectSetUpTask.java:109)
      at com.intellij.ide.startup.impl.StartupManagerImpl$7.run(StartupManagerImpl.java:286)
      at com.intellij.ide.startup.impl.StartupManagerImpl$8.run(StartupManagerImpl.java:297)
      at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057)
      at com.intellij.ide.startup.impl.StartupManagerImpl.runWhenProjectIsInitialized(StartupManagerImpl.java:294)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask.populateProject(ProjectSetUpTask.java:106)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask.access$000(ProjectSetUpTask.java:46)
      at com.android.tools.idea.gradle.project.ProjectSetUpTask$1.run(ProjectSetUpTask.java:68)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
      at java.awt.EventQueue.access$400(EventQueue.java:82)
      at java.awt.EventQueue$2.run(EventQueue.java:676)
      at java.awt.EventQueue$2.run(EventQueue.java:674)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
      at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    2014-12-02 01:39:47,768 [1279694]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 2 ms 
    2014-12-02 01:39:47,768 [1279694]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update 
    2014-12-02 01:39:47,768 [1279694]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms 
    2014-12-02 01:39:47,884 [1279810]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home 
    

    Details

    Project's build.gradle

    buildscript {
        repositories {
            mavenCentral()
            maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.+'
            classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.+'
        }
    }
    
    ext {
        compileSdkVersion = 21
        buildToolsVersion = '21.1.1'
        minSdkVersion = 8
        targetSdkVersion = 21
    }
    

    Lib's build.gradle

    apply plugin: 'com.android.library'
    
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    
    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
        buildToolsVersion rootProject.ext.buildToolsVersion
    
        defaultConfig {
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
    }
    
    apply plugin: 'android-unit-test'
    
    dependencies {
        compile 'com.android.support:support-v4:19.+'
        // Robolectric tests (change to testCompile, when android-unit-test is ready)
        testCompile 'junit:junit:4.11'
        testCompile 'org.mockito:mockito-core:1.9.5'
        testCompile 'com.squareup:fest-android:1.0.+'
        testCompile('org.robolectric:robolectric:2.4') {
            exclude module: 'classworlds'
            exclude module: 'commons-logging'
            exclude module: 'httpclient'
            exclude module: 'maven-artifact'
            exclude module: 'maven-artifact-manager'
            exclude module: 'maven-error-diagnostics'
            exclude module: 'maven-model'
            exclude module: 'maven-plugin-registry'
            exclude module: 'maven-profile'
            exclude module: 'maven-project'
            exclude module: 'maven-settings'
            exclude module: 'nekohtml'
            exclude module: 'plexus-container-default'
            exclude module: 'plexus-interpolation'
            exclude module: 'plexus-utils'
            exclude module: 'wagon-file'
            exclude module: 'wagon-http-lightweight'
            exclude module: 'wagon-http-shared'
            exclude module: 'wagon-provider-api'
        }
    }
    

    Gradle version - 2.2 or 2.2.1. /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

    opened by almozavr 12
  • Plugin and Android Gradle 0.14.2 / Androud Studio 0.9.3 is not working

    Plugin and Android Gradle 0.14.2 / Androud Studio 0.9.3 is not working

    We just upgraded to Android gradle plugin 0.14.2 and Android Studio 0.9.3 and now have issues with this plugin (worked great on 0.13 / 0.8.14).

    On loading the project, we get the below warning. Running the tests don't work anymore and just says it can't find any classes from dependencies / other modules. (Yes, we have set up dependencies as mentioned in troubleshooting - this all worked fine prior to upgrading).

    com.android.builder.model.Dependencies.getLibraries()Ljava/util/List;: com.android.builder.model.Dependencies.getLibraries()Ljava/util/List; java.lang.NoSuchMethodError: com.android.builder.model.Dependencies.getLibraries()Ljava/util/List; at me.tatarka.androidunittest.idea.DependenciesModuleCustomizer.setUpDependencies(DependenciesModuleCustomizer.java:47) at me.tatarka.androidunittest.idea.DependenciesModuleCustomizer.setUpDependencies(DependenciesModuleCustomizer.java:35) at me.tatarka.androidunittest.idea.AbstractDependenciesModuleCustomizer.customizeModule(AbstractDependenciesModuleCustomizer.java:62) at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.customizeModule(AndroidUnitTestDataService.java:82) at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.access$100(AndroidUnitTestDataService.java:26) at me.tatarka.androidunittest.idea.AndroidUnitTestDataService$1.execute(AndroidUnitTestDataService.java:73) at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:374) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359) at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.doImport(AndroidUnitTestDataService.java:66) at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.importData(AndroidUnitTestDataService.java:48) at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:90) at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:74) at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:98) at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1$1.run(ProjectSetUpTask.java:117) at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:329) at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1.execute(ProjectSetUpTask.java:112) at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361) at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:381) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:355) at com.android.tools.idea.gradle.project.ProjectSetUpTask$2.run(ProjectSetUpTask.java:109) at com.intellij.ide.startup.impl.StartupManagerImpl$7.run(StartupManagerImpl.java:286) at com.intellij.ide.startup.impl.StartupManagerImpl$8.run(StartupManagerImpl.java:297) at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057) at com.intellij.ide.startup.impl.StartupManagerImpl.runWhenProjectIsInitialized(StartupManagerImpl.java:294) at com.android.tools.idea.gradle.project.ProjectSetUpTask.populateProject(ProjectSetUpTask.java:106) at com.android.tools.idea.gradle.project.ProjectSetUpTask.access$000(ProjectSetUpTask.java:46) at com.android.tools.idea.gradle.project.ProjectSetUpTask$1.run(ProjectSetUpTask.java:68) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715) at java.awt.EventQueue.access$400(EventQueue.java:82) at java.awt.EventQueue$2.run(EventQueue.java:676) at java.awt.EventQueue$2.run(EventQueue.java:674) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86) at java.awt.EventQueue.dispatchEvent(EventQueue.java:685) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    bug 
    opened by borgelino 9
  • How to setup this project

    How to setup this project

    Can you explain what i must do to get this project compile?

    I like to see whether this could be ported to support https://github.com/novoda/gradle-android-test-plugin I like to have the possibility to use robolectric in a separate module. But it need some configuration/hacks to use it inside android studio.

    opened by nenick 8
  • NoClassDefFoundError for dependency

    NoClassDefFoundError for dependency

    Hi there, I'm having an issue while setting up Junit test to use real AndroidManifest.xml. My test class is:

    @Config(manifest = "AndroidManifest.xml", emulateSdk = 18)
    @RunWith(RobolectricTestRunner.class)
    public class StringUtilsTest {
    ...
    }
    

    Unfortunately, I'm getting NoClassDefFoundError exception when running this test inside Android Studio.

    WARNING: no system properties value for ro.build.date.utc
    DEBUG: Loading resources for it.sephiroth.android.library from ./../HorizontalListviewLib/res...
    DEBUG: Loading resources for com.google.android.gms from ./../google-play-services_lib/res...
    DEBUG: Loading resources for com.facebook.android from ./../facebook-android-sdk-3.15.0/facebook/res...
    DEBUG: Loading resources for com.nostra13.universalimageloader from ./../UniversalImageLoader/res...
    DEBUG: Loading resources for com.android.volley from ./../volley/res...
    
    java.lang.NoClassDefFoundError: com/nostra13/universalimageloader/cache/memory/MemoryCache
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:190)
        at org.robolectric.internal.ClassNameResolver.safeClassForName(ClassNameResolver.java:37)
        at org.robolectric.internal.ClassNameResolver.resolve(ClassNameResolver.java:15)
        at org.robolectric.DefaultTestLifecycle.createApplication(DefaultTestLifecycle.java:56)
        at org.robolectric.DefaultTestLifecycle.createApplication(DefaultTestLifecycle.java:14)
        at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:115)
        at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:456)
        at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:253)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:194)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    

    I can run this test with command line. It might be something wrong with my configuration, could anyone give me some advices?

    Thanks

    opened by jupiter2359media 6
  • `test/java` directory not marked in Android Studio Beta 0.8.2

    `test/java` directory not marked in Android Studio Beta 0.8.2

    I installed version 1.0 of this plugin and created a test/java directory in my app's module. However, it is not marked. I am using Android Studio Beta 0.8.2.

    opened by codeguru42 5
  • Test sourceSet not marked for android library modules

    Test sourceSet not marked for android library modules

    I have a project which is set up similar to: https://github.com/JCAndKSolutions/android-unit-test/tree/master/example

    • an app module (build.gradle: apply plugin: 'com.android.application')
    • a library module (build.gradle: apply plugin: 'com.android.library') For both modules I've applied the android-unit-test gradle plugin, but:
    • for the library module the test source set is not properly marked in android studio as test sources and I cannot run the tests
    • app module works just fine

    I figured out, that when I manually edit the librarie's .iml file I can fix this. What I had to change was:

    • add: <output-test url="file://$MODULE_DIR$/build/test-classes/debug" />
    • add: <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
    • add: <orderEntry type="library" exported="" scope="TEST" name="junit-4.11" level="project" />
    • and add: <orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" /> and then I'm able to run junit tests just fine...
    opened by schroepf 4
  • If build don't compile for any reason the plugin throw an exception

    If build don't compile for any reason the plugin throw an exception

    Using the last AS 1.0 RC4

    java.lang.NullPointerException
        at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:37)
        at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:23)
        at me.tatarka.androidunittest.idea.AbstractContentRootModuleCustomizer.customizeModule(AbstractContentRootModuleCustomizer.java:51)
        at me.tatarka.androidunittest.idea.AndroidStudioGradleUnitTestPluginComponent.updateModule(AndroidStudioGradleUnitTestPluginComponent.java:76)
        at me.tatarka.androidunittest.idea.AndroidStudioGradleUnitTestPluginComponent.access$000(AndroidStudioGradleUnitTestPluginComponent.java:19)
        at me.tatarka.androidunittest.idea.AndroidStudioGradleUnitTestPluginComponent$1$1.run(AndroidStudioGradleUnitTestPluginComponent.java:58)
        at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
        at me.tatarka.androidunittest.idea.AndroidStudioGradleUnitTestPluginComponent$1.buildVariantSelected(AndroidStudioGradleUnitTestPluginComponent.java:54)
        at com.android.tools.idea.gradle.variant.view.BuildVariantView$2.run(BuildVariantView.java:459)
        at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:319)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:676)
        at java.awt.EventQueue$2.run(EventQueue.java:674)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
        at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
        at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
        at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    
    bug 
    opened by ffgiraldez 4
  • Using the plugin with Sprinkles -

    Using the plugin with Sprinkles -

    Running the test with the CLI with the general command works fine:

    $ ./gradlew test
    

    -> All the test pass.

    The IDE is trying to start the tests with the following (gradle console):

    $ ./gradlew library:compileDebugTestJava
    

    It complains that it doesn't fin JUnit, nor Robolectric. Manually triggering the tasks on the CLI doesn't work neither.

    The project I'm trying to run is an Android Library. You can find the source code on github. I feel like the structure of the project does not comply to some assumptions that the plugin makes. I've tried to move everything and tests different combination but can't make this work. Any hint?

    opened by fstephany 0
  • Add default VM options to test runs

    Add default VM options to test runs

    I have a project set up with android-unit-test and android-studio-unit-test-plugin. When I right-click on a Robolectric test class and run it as a JUnit test, the test fails with a VerifyError. See https://github.com/robolectric/robolectric/issues/1186.

    The current workaround is to add -noverify as a VM argument. I've been able to do this with the following block in my build.gradle file. When I run tests on the command line (./gradlew test), the tests work properly.

    androidUnitTest {
        testTasks {
            all {
                jvmArgs '-noverify'
            }
        }
    }
    

    This configuration doesn't translate to the automatically generated run configurations in Android Studio when I run a single test class. I also haven't had any luck modifying the default JUnit configuration in the Edit Configurations dialog. Instead, my workaround is to try to run a test, modify the automatically generated run configuration to add -noverify to the VM options, then run the test again.

    As a feature request, I'd like a way to set default VM options to be added to every test run.

    opened by wesleym 6
  • Running tests from IDE does not recompile test classes

    Running tests from IDE does not recompile test classes

    Android Studio: 1.0.1 android-unit-test: 2.1.1 android-studio-unit-test-plugin: 1.4.0

    It appears that recent changes to this plugin have attempted to add a make task before running the unit tests that should run with a goal of testDebugClasses, but it only seems to be running with a goal of assembleDebug anyway.

    Therefore, after a project cleaning, I get the ClassNotFound error until I build from the command line.

    Also, if I make changes to the tests, they don't get recompiled when I run the tests from the IDE.

    opened by gbegen 6
  • Support for testTasks

    Support for testTasks

    android-unit-test plugin added support for testTasks, which allows jvm and system props to be passed into tests. https://github.com/JCAndKSolutions/android-unit-test/commit/9506e3b2cb004cf5fb6d41c55f63492a9fc83df3

    Possible future feature enhancement for the android studio plugin?

    opened by bjohnson20 0
  • Plugin Uses testCompile as well as androidTestCompile

    Plugin Uses testCompile as well as androidTestCompile

    Hi There,

    I just was trying out your plugin and found out that it somehow uses both dependencies:

    the ones from testCompile for the robolectric plugin as well as androidTestCompile which ich use to run my androidUnitTest / EspressoTests.

    Could you check if this is true because if i comment the androidTestCompile out it isn't compiling.

    If i run the stuff on command line everything works fine

    Additionally the plugin overrides for example the jvmArgs or doesn't inherit the arguments from the junit template or robolectric plugin (version 2.1.1)

    Cheers Neristance

    opened by Neristance 2
Owner
Evan Tatarka
Evan Tatarka
A tool to convert unit tests from one standard to another

unit-test-exchange-maven-plugin This plugin works as a tool to convert unit test

null 1 Feb 3, 2022
✈️ IDE plugin for the IntelliJ platform which adds GitHub Copilot support. (VERY WIP)

JetBrains Copilot GitHub Copilot support for the IntellIJ Platform. Installation Download the latest release. Select the Install Plugin from Disk opti

Koding 155 Dec 10, 2022
Helper to upload Gradle Android Artifacts, Gradle Java Artifacts and Gradle Kotlin Artifacts to Maven repositories (JCenter, Maven Central, Corporate staging/snapshot servers and local Maven repositories).

GradleMavenPush Helper to upload Gradle Android Artifacts, Gradle Java Artifacts and Gradle Kotlin Artifacts to Maven repositories (JCenter, Maven Cen

 Vorlonsoft LLC 21 Oct 3, 2022
Gradle Replace In Place (GRIP): a gradle plugin to update your documentation or any file with a simple gradle task

GRIP (Gradle Replace In-Place) A gradle tool to update some values in your (documentation) files by running a task. (inspired by Knit) Directives Inse

Grégory Lureau 2 Oct 18, 2022
gradle-android-scala-plugin adds scala language support to official gradle android plugin

gradle-android-scala-plugin gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at htt

saturday06 345 Dec 10, 2022
Kotlin Multiplatform (pending KSP support) snapshot (klip) manager for tests

KLIP Kotlin Multiplatform (pending KSP support) snapshot (klip) manager for tests Modules core - runtime library processor - ksp-based annotation proc

Martynas Petuška 23 Nov 25, 2022
This plugin allows creating or editing Excalidraw virtual whiteboard within the IDE.

Excalidraw Integration for Jetbrains IDEs This plugin allows creating or editing Excalidraw virtual whiteboard within the IDE. Installation Using IDE

Brice Dutheil 46 Dec 11, 2022
Provides a shortcut to copy permalink in their online Git repositories from inside IDE.

Copy Git Link Provides a shortcut to copy permalink in their online Git repositories from inside IDE. Works with: GitHub GitLab Bitbucket My.Movie.4.3

ryo 13 Jan 3, 2023
A plugin for Jetbrains IDE, Your code is powerful, unleash it like playing osu!

Osu! Mode A plugin for Jetbrains IDE, Your code is powerful, unleash it like playing osu! Demo 2021-10-15.18-50-30.mp4 Bilibili Feature open project /

Nthily 8 Sep 8, 2022
Leader key for IntelliJ-based IDE's. Now IdeaVim-friendly!

Ataman Ataman - an elected leader of the Cossack troops and settlements Ataman is an Intellij Idea plugin for using leader key for bindings (almost li

Mikhail Levchenko 50 Dec 13, 2022
An IDE plug-in for quick access to Jetpack Compose controls

An IDE plug-in for quick access to Jetpack Compose controls

Jetpack Compose Museum 17 Aug 28, 2022
Manage pull requests and conduct code reviews in your IDE with full source-tree context.

String Manipulation IntelliJ plugin - https://plugins.jetbrains.com/plugin/2162 Sponsored by Manage pull requests and conduct code reviews in your IDE

Vojtěch Krása 582 Dec 22, 2022
Ownership-gradle-plugin - Gradle code ownership verification plugin

Gradle code ownership verification plugin A gradle plugin that will verify owner

null 4 Dec 15, 2022
A Gradle plugin to support the Groovy language for building Android apps

Groovy language support for Android Deprecated: This plugin has been deprecated in favor of Kotlin which has the full support of JetBrains and Google.

Groovy programming language 853 Dec 21, 2022
IntelliJ plugin that provides some useful utilities to support the daily work with Gradle.

IntelliJ Gradle Utilities Plugin This IntelliJ plugin provides some useful utilities to support the daily work with Gradle. It's available on the offi

Marcel Kliemannel 6 Jul 29, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022
IntelliJ / Android Studio plugin for Android Holo Colors

This project is not maintained anymore. Holo Colors doesn't make sense since the introduction of Material Design and the ability to set the primary co

Jérôme Van Der Linden 644 Nov 10, 2022
ADB WIFI Android Studio plugin for debug android app over Wi-Fi.

ADB WIFI ADB WIFI Android Studio plugin for debug android app over Wi-Fi. How to install in Android Studio: go to Preferences

Sutachad Wichai 298 Jan 3, 2023
Android Studio plug-in for generating ButterKnife injections from selected layout XML.

ButterKnifeZelezny Simple plug-in for Android Studio/IDEA that allows one-click creation of Butterknife view injections. How to install in Android Stu

Avast 3.4k Dec 14, 2022