evant = Eva New Technologyβ’
evant / android-studio-unit-test-plugin Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.
[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.
Using AS 0.8.6, the plugin appeared to be working for me briefly, but now I'm getting the following behavior:
At step 4, it appears that AS no longer recognizes that the class has any unit tests until I go through the sequence above, where it sees the unit tests briefly, and then seconds later, it no longer recognizes them again.
The tests are in src/testDebug/java
Hi,
When adding a new test method to an existing test class and directly executing the changed source file, the plugin does not pick up the new test method. It can only be executed after having executed the tests on the command line.
Matthias
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
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?
I have a project which is set up similar to: https://github.com/JCAndKSolutions/android-unit-test/tree/master/example
apply plugin: 'com.android.application'
)apply plugin: 'com.android.library'
)test
source set is not properly marked in android studio as test sources and I cannot run the testsI figured out, that when I manually edit the librarie's .iml
file I can fix this. What I had to change was:
<output-test url="file://$MODULE_DIR$/build/test-classes/debug" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
Recently update from version .84 to .89, since the upgrade right clicking on a test and debugging it and having the default make task execute first no longer compiles the test sources. Investigating futher, It seems like the test directory is no longer compiled in the assembledebug task run by make.
Workaround was to run external tool and run testDebugClasses but that starts a new gradle instance each time instead of using the daemon that studio has running. I'm using the android unit test plugin as well.
Similar to http://stackoverflow.com/q/3963708/693752
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
I like the way to use tasks.findByName("assembleDebug").dependsOn("testDebugClasses")
but i have issues to use this way with a multi module setup. One module is an Android application and the other one is an Android library module which is used by the application module.
When using the dependsOn way i have to write the dependsOn line in both build.gradle files. The line only works at the application module. The line at both or only at the library module throws following error.
Circular dependency between the following tasks:
:Data:assembleDebug
\--- :Data:testDebugClasses
\--- :Data:compileTestDebugJava
\--- :Data:mergeDebugTestResources
+--- :Data:assembleDebug (*)
\--- :Data:generateDebugTestResources
\--- :Data:compileDebugTestRenderscript
\--- :Data:processDebugTestManifest
\--- :Data:assembleDebug (*)
To support multi module project i can use the second way with the run configuration but i prefer the other one.
So the question is, have you an idea to support the dependsOn way on multi module projects with android studio?
I have added the gradle dependency for the library but the sync fails. Please help.
It appears that there's no testRelease generated?
Running IntelliJ IDEA EAP v138.2210.3 and getting the following error when attempting to build a project when this plugin is enabled:
2014-09-27 16:10:11,615 [ 672120] WARN - nal.AbstractExternalSystemTask - me/tatarka/androidunittest/model/AndroidUnitTest
com.intellij.openapi.externalSystem.model.ExternalSystemException:at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:214)
Let me know if there is anything I can to to produce more detailed log. This is all I got from idea.log
Hi,
I've set up android-unit-test and it seems close to run tests in Android Studio, but when I tried to run a junit from AS, I got following error:
Error running Unnamed: No junit.jar in Module 'AndroidTestPractice' runtime scope
Here's what I have done:
AndroidTestPractice/app/test/java/SimpleTest.java
. java
directory is recognized as test folder.AndroidTestPractice/app/build.gradle
has followings:apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "gaku.net.androidtestpractice"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'android-unit-test'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.3'
}
-ea
/Users/gaku/src/AndroidTestPractice
What did I miss? junit is in dependencies.
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)
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)
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.
Simple project with sample and library structure:
--Project
----Sample
----Library
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
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
When working through the config with you we think we found that the flavor names as created in camel case did not work with the plugin. This is a note to check on that.
There might be something related to scope of test dependencies, like if provided were added to the app under tests maybe..
Should that work ?
Robolectric supports custom configuration via annotations or properties files (http://robolectric.blogspot.com.au/2013/05/configuring-robolectric-20.html). We have a project where we are setting the emulateSdk property to use API level 16, as Robolectric doesn't support what we target (15). This is not getting picked up by this plugin which ends up with Robolectric complaining about the API level. It works fine when we run it command line.
Is there any way of enabling this for this plugin?
My test folder contains Robolectric and JUnit tests.
Some of those tests are fetching files from a resource folder located inside the test folder.
When running the test gradle task, the tests can use the files places in resource folder and everything works well.
The same tests fail to find the resource files when running with the JUnit test runner.
I'm not sure if this is an issue with the IDE plugin or with JCAndKSolutions' android-unit-test gradle plugin.
Is it related to JCAndKSolutions/android-unit-test#80 ?
For some reason, at every gradle sync, the VM options in my Robolectric juint configuration change to this, if I remove this, it starts working again.
-Dandroid.manifest="/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/manifests/debug/AndroidManifest.xml" -Dandroid.resources="/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/test-resources/Debug/res" -Dandroid.package="com.kiwiwearables.app" -Dandroid.assets="/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/assets/debug" -classpath /Users/afzal/Dev/Kiwi/kiwi-android/common/build/intermediates/classes/debug:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/classes/debug:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/test-classes/debug:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/classes/debug:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.3.4/3b646ddbdac8a33fc45b64564011da81d23e4635/picasso-2.3.4.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/15.0/ed727a8d9f247e2050281cb083f1c77b09dcb5cd/guava-15.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.crashlytics.android/crashlytics/1.1.13/e821eafa1bf489a26bdb71f95078c26785b37a1/crashlytics-1.1.13.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.nhaarman.listviewanimations/library/2.6.0/59351ccb0a1631d30358f6a92749a072f2df7602/library-2.6.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.koushikdutta.ion/ion/1.3.8/1fc0413880bde2e3ffab3c5e5a243f39dd409b1c/ion-1.3.8.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.cloudant/cloudant-sync-datastore-core/0.7.1/67e33dcd066bb5a1448a90d5f68e6b90bd461b27/cloudant-sync-datastore-core-0.7.1.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.google.android.gms/play-services/5.0.89/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.google.android.gms/play-services/5.0.89/res:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/libs/internal_impl-20.0.0.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/res:/Users/afzal/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.4/b1b6ea3b7e4aa4f492509a4952029cd8e48019ad/commons-io-2.4.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.squareup/otto/1.3.5/7941cd2c2c8ec006800d75c35f8a9dacf892ab93/otto-1.3.5.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.akexorcist/bluetoothspp/1.2/res:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.akexorcist/bluetoothspp/1.2/classes.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.4.1.1/f1b322a9ff873aee0b710af5f33bc10a2eb019ba/jackson-core-2.4.1.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.0/5871fb60dc68d67da54a663c3fd636a10a532948/jsr305-3.0.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.4.0/d6a66c7a5f01cf500377bd669507a08cfeba882a/jackson-annotations-2.4.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit/retrofit/1.6.1/efb0a36546aa8857ab8df358b106c1817e03cbee/retrofit-1.6.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.mixpanel.android/mixpanel-android/4.3.1/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/exploded-aar/com.mixpanel.android/mixpanel-android/4.3.1/res:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.koushikdutta.async/androidasync/1.3.8/1f8e4f77d5f24179688c32b24dd5f79e889e7110/androidasync-1.3.8.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.cloudant/cloudant-sync-datastore-android/0.7.1/d9a72f531bf9bf490b297d0c3b16d43dcb13a1d8/cloudant-sync-datastore-android-0.7.1.jar:/Users/afzal/Dev/android/android-sdk-macosx/extras/android/m2repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.4.1.3/337a63173c2950939158544315ce6d49c19d84a8/jackson-databind-2.4.1.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.nineoldandroids/library/2.4.0/e9b63380f3a242dbdbf103a2355ad7e43bad17cb/library-2.4.0.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3/5fc52c41ef0239d1093a1eb7c3697036183677ce/gson-2.3.jar:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.android.support/support-v13/20.0.0/res:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.android.support/support-v13/20.0.0/libs/internal_impl-20.0.0.jar:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.android.support/support-v13/20.0.0/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/5.0.77/res:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/5.0.77/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.google.android.support/wearable/1.0.0/classes.jar:/Users/afzal/Dev/Kiwi/kiwi-android/wear/build/intermediates/exploded-aar/com.google.android.support/wearable/1.0.0/res:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.8.0/8b53ba16fa62fb1034da8f1de200ddc407c8381/ant-launcher-1.8.0.jar:/Users/afzal/Dev/Kiwi/kiwi-android/common/build/outputs/aar/common.aar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/5.0.1/1b1e6e9d869acd704056d0a4223071a511c619e6/asm-tree-5.0.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-commons/5.0.1/7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e/asm-commons-5.0.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.json/json/20080701/d652f102185530c93b66158b1859f35d45687258/json-20080701.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/2.3/45dfeecf071f1f234961f80c64edccf1edb4d374/robolectric-2.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/5.0.1/7c8caddfbd0b2d7b844f8fcc75175b9cb9cf4724/asm-util-5.0.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/xerces/xmlParserAPIs/2.6.2/65acede1e5305bd2b92213d7b5761328c6f4fd9/xmlParserAPIs-2.6.2.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/5.0.1/e286fbee48efacb4e7c175f7948d9d8b2ab52352/asm-analysis-5.0.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.google.android/android/4.0.1.2/b680f76fe4056656da02374ad93a4c7a4c2c3512/android-4.0.1.2.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.ximpleware/vtd-xml/2.11/ee5bcf62c1acf76434ee9f1c67a840bafef72a6d/vtd-xml-2.11.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.2.2/b76bee23cd3f3ee9b98bc7c2c14670e821ddbbfd/httpcore-4.2.2.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.0.1/2fd56467a018aafe6ec6a73ccba520be4a7e1565/asm-5.0.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.easytesting/fest-util/1.2.5/c4a8d7305b23b8d043be12c979813b096df11f44/fest-util-1.2.5.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.squareup/fest-android/1.0.8/72b0763d5fd11a9ca769bb88367d92e43c0198e0/fest-android-1.0.8.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.6/b7f0fc8f61ecadeb3695f0b9464755eee44374d4/commons-codec-1.6.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/com.almworks.sqlite4java/sqlite4java/0.282/745a7e2f35fdbe6336922e0d492c979dbbfa74fb/sqlite4java-0.282.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-ant-tasks/2.1.3/b09be554228d66d208e5fef5266844aacf443abc/maven-ant-tasks-2.1.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.easytesting/fest-reflect/1.4.1/2b92d5275e92a49e16c7ce6bd7e46b9080db0530/fest-reflect-1.4.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.1/5043bfebc3db072ed80fbd362e7caf00e885d8ae/commons-logging-1.1.1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.2.3/37ced84d839a02fb856255eca85f0a4be95aa634/httpclient-4.2.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/xpp3/xpp3/1.1.4c/9b988ea84b9e4e9f1874e390ce099b8ac12cfff5/xpp3-1.1.4c.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.objenesis/objenesis/1.3/dc13ae4faca6df981fc7aeb5a522d9db446d5d50/objenesis-1.3.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.easytesting/fest-assert-core/2.0M10/cb7c91cf614901928ae405f19d9bcdedf82781db/fest-assert-core-2.0M10.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.khronos/opengl-api/gl1.1-android-2.1_r1/8827d279add29cf9115820671e7879de7bf80390/opengl-api-gl1.1-android-2.1_r1.jar:/Users/afzal/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.0/7b456ca6b93900f96e58cc8371f03d90a9c1c8d1/ant-1.8.0.jar:/Users/afzal/Dev/android/android-sdk-macosx/platforms/android-20/android.jar:/Users/afzal/Dev/android/android-sdk-macosx/platforms/android-20/data/res:/Users/afzal/Dev/android/android-sdk-macosx/tools/support/annotations.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/intermediates/classes/debug:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/build/test-classes/debug:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/src/testDebug/resources:/Users/afzal/Dev/Kiwi/kiwi-android/mobile/src/test/resources:/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar
Same issue I had was raised in the android bug tracker.
https://code.google.com/p/android/issues/detail?id=160899
So I've followed these instructions on how to use the unit test plugin with depdencies to a android-library-project, which also have unit tests.
This works as in the test compiles and runs, but IntelliJ IDEA does not pick up on the test. I.e. they are listed as "red files" instead of green. This makes development harder as you do not get autocomplete and such.
Any suggestions on how to fix this? Is this merely a configuration thing? If you'd like I can upload a sample project to illustrate the problem.
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.
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?
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
Robolectric allows to place its configuration in a special config file org.robolectric.Config.properties
that usually resides in src/test/resources
. While this is correctly picked up when I execute ./gradlew test
on command line, it isn't when I run the test through Android Studio.
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!
Upgrading to 1.3.0 i fix the issue with AS (1.0-RC) but using the command line all my tests pass OK
from IDE i get the exception here
InputStream inputStream = getClass().getResourceAsStream(String.format("/%s.json", fileName));
probably something with the classpath settings
actually the file is located under src/test/resources/
IDE check it as test resource folder other folder like src/testDebug/resources
not checked correctly
android-unit-test plugin added support for testTasks, which allows jvm and system props to be passed into tests. JCAndKSolutions/android-unit-test@9506e3b
Possible future feature enhancement for the android studio plugin?
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
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 robolectric/robolectric#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.
Not sure if this is something for you to look at or not in the plugin, but we found that when running robolectric tests from the command line that the manifest path is relative to the app root, whereas when running the test from Android Studio the path is relevant to the project root. i.e.
src/main/TestAndroidManifest.xml
versus
platform/src/main/TestAndroidManifest.xml
where the project structure is: myAndroidProject/platform/src/...
android-unit-test plugin is not found
I am collaborating with a friend on a project. He develops on a linux box, and I work on a windows one (sorry, I love playing games :( ). Using the exact same project files, I was unable to run the unit tests within Android Studio, but he could. We're using app support v7. When I tried to run the unit test I would get this error. The interesting part is the java.lang.NoSuchFieldError: ActionBarWindow
which comes from the app support v7 classes not being available on the classpath.
Please note that if I ran ./gradlew test for our project, it would run the test and it would pass without incident, so this is specific to the Android Studio plugin.
After much confusion I tried adding this line so that the dependency would be forced into the androidTestCompile configuration. My guess is that there is something wrong with the way that the plugin is, or is not, copying dependencies named in the "compile" configuration.
'androidTestCompile 'com.android.support:appcompat-v7:21.0.3'
Here is the error I would get.
DEBUG: Loading classes from: file:/C:/Users/Jazzepi/.m2/repository/org/robolectric/android-all/5.0.0_r2-robolectric-0/android-all-5.0.0_r2-robolectric-0.jar
DEBUG: Loading classes from: file:/C:/Users/Jazzepi/.m2/repository/org/robolectric/shadows-core/3.0-SNAPSHOT/shadows-core-3.0-SNAPSHOT-21.jar
DEBUG: Loading classes from: file:/C:/Users/Jazzepi/.m2/repository/org/json/json/20080701/json-20080701.jar
DEBUG: Loading classes from: file:/C:/Users/Jazzepi/.m2/repository/org/ccil/cowan/tagsoup/tagsoup/1.2/tagsoup-1.2.jar
DEBUG: Loading resources for com.companyname.dml from C:\repos\DirtyMadLibs-Android\dml\build\intermediates\res\dev\debug...
DEBUG: Loading resources for android from jar:C:\Users\Jazzepi\.m2\repository\org\robolectric\android-all\5.0.0_r2-robolectric-0\android-all-5.0.0_r2-robolectric-0.jar!/res...
java.lang.NoSuchFieldError: ActionBarWindow
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:106)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
at com.companyname.dml.ui.DirtyActivity.onCreate(DirtyActivity.java:37)
at com.companyname.dml.ui.landing.LandingActivity.onCreate(LandingActivity.java:48)
at android.app.Activity.performCreate(Activity.java:5933)
at org.robolectric.util.ReflectionHelpers$3.run(ReflectionHelpers.java:144)
at org.robolectric.util.ReflectionHelpers.traverseClassHierarchy(ReflectionHelpers.java:241)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:138)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:114)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:309)
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:47)
at org.robolectric.util.ActivityController.create(ActivityController.java:110)
at org.robolectric.util.ActivityController.create(ActivityController.java:121)
at org.robolectric.util.ActivityController.setup(ActivityController.java:202)
at org.robolectric.Robolectric.setupActivity(Robolectric.java:41)
at com.companyname.dml.LoginTest.setup(LoginTest.java:32)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234)
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:167)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Here is the WORKING build.gradle file. To reproduce just remove the androidTestCompile 'com.android.support:appcompat-v7:21.0.3' line.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// classpath 'org.robolectric:robolectric-gradle-plugin:0.14.+'
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'
}
}
allprojects {
repositories {
jcenter()
}
}
// Manifest version information!
def versionMajor = 0
def versionMinor = 1
def versionPatch = 0
def versionBuild = 1 // bump for dogfood builds, public betas, etc.apply plugin: 'android'
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
android {
dexOptions {
preDexLibraries = false
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
// applicationId "com.companyname.dml"
multiDexEnabled true
testInstrumentationRunner "android.support.multidex.MultiDexTestRunner"
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 14
}
}
buildTypes {
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
}
release {
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
}
sourceSets {
instrumentTest.setRoot('src/test')
androidTest.setRoot('src/test')
}
}
apply plugin: 'android-unit-test'
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:support-annotations:21.0.0'
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.jakewharton.timber:timber:2.4.1'
// To be Rx or not to be Rx? Who knows
compile 'io.reactivex:rxjava:1.0.4'
compile 'io.reactivex:rxandroid:0.23.0'
compile 'com.github.matthewyork:ColoursLibrary:1.0.0@aar'
compile ('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.github.frankiesardo:icepick:2.3.6'
provided 'com.github.frankiesardo:icepick-processor:2.3.6'
compile 'nl.qbusict:cupboard:2.1.1'
compile 'org.lucasr.twowayview:core:1.0.0-SNAPSHOT@aar'
compile 'org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT@aar'
// Testing
testCompile 'com.android.support:multidex-instrumentation:1.0.1'
testCompile "junit:junit:4.10"
testCompile "org.assertj:assertj-core:1.7.0"
testCompile "org.robolectric:robolectric:3.0-SNAPSHOT"
testCompile 'org.assertj:assertj-core:1.7.1'
androidTestCompile 'com.android.support:appcompat-v7:21.0.3'
androidTestCompile 'com.squareup.assertj:assertj-android:1.0.0'
androidTestCompile 'com.squareup.assertj:assertj-android-support-v4:1.0.0'
androidTestCompile 'com.squareup.assertj:assertj-android-appcompat-v7:1.0.0'
}
Since AS 0.8.4 they added a new Project View called Android
. This view groups all source code under the java
folder even if from different flavors or build types. It groups the resources under res
and further subgroups like layout
and finally the resource name. if different version of the same resource exist it will group them under the resource name. and so on. It will also group manifests and such.
The thing is the test
folder disappears under this view. I'm assuming because this view is not expecting it. I'm not sure if your plugin can do anything about it or if we would need the AS team to open an API for us or something.
Otherwise I have to be switching from Android
view to Project
view to see the tests.
Thanks.
When I add new test method to test class and run all Tests from Android Studio the new method will not be evaluated. Same thing is when I delete method.
So far I have found that if I call gradle test
from terminal and then rerun tests from Android Studio everything works fine, but with that I need to run tests twice.
I'm using:
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.
Please add a link to :
https://github.com/JCAndKSolutions/android-unit-test
for easier navigation
I built a very simple project with the following modules:
If I add the library
module as a dependency of mobile
, the testClasses
Gradle task launched by the plugin does not generate the test classes (in build/test-classes
) needed to run the tests. As a result, when trying to run any of the tests the following message is displayed:
Class not found: "<full.qualified.name.of.the.class.of.the.test.Test>"
However, if I remove the dependency, the classes are correctly generated and the tests can run. (Note: The dependency with the library is not used in this sample project, but it's the purpose of the it)
I know the android-unit-test Gradle plugin does not support Android libraries yet, but I'm surprised that if I run ./gradle test
from the command line the test-classes are correctly generated and the tests can run.
Any idea why this is happening just when running the tests from the IDE (i.e. using the Android Studio test plugin)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.