android-studio-unit-test-plugin icon indicating copy to clipboard operation
android-studio-unit-test-plugin copied to clipboard

testClasses task does not generate test-classes when an android-library dependency exists

Open ChristianGarcia opened this issue 12 years ago • 3 comments

I built a very simple project with the following modules:

  • mobile: Android Application module
  • library: Android library module

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)?

ChristianGarcia avatar Aug 03 '14 11:08 ChristianGarcia

This is a known issue, (look at #5). For some reason, the IDE is not running the testClasses gradle task in this case.

evant avatar Aug 03 '14 15:08 evant

You're right, it's the same issue. If it helps, it happens in Android Studio 0.8.4 as well. The sample project I provided in the description can help to test it.

ChristianGarcia avatar Aug 03 '14 18:08 ChristianGarcia

Closing as a duplicate of #5, that way I can keep all discussion about this issue in one place. Good news is that I found a work arround.

evant avatar Aug 05 '14 04:08 evant