This is a function of a lack of support for multiple test source sets in a single module by Android Studio. If this was remedied what actual use case would there be for depending on an app module?
On Tue, Oct 7, 2014 at 6:45 PM, Michael Wallstedt <[email protected]> wrote: > The following blog outlines a solution for having test code depend upon > the application directly. This seems like a somewhat elaborate workaround > for what should be a fairly common case. Is there a better way? > > > http://blog.blundell-apps.com/android-gradle-app-with-robolectric-junit-tests/ > > On Thursday, July 24, 2014 5:39:59 PM UTC-7, Siva Velusamy wrote: >> >> Thanks for the test case. I understand your question now, and yes, I >> don't think depending on an Android application would work. You'd either >> put your tests inside your app itself, or create a jar. >> >> >> On Thu, Jul 24, 2014 at 2:53 PM, Michael Wallstedt <[email protected]> >> wrote: >> >>> I've attached a simple application that demonstrates the issue. With >>> this example, if I invoke the gradle task project-test:compileDebugJava, >>> the compilation fails with: >>> >>> /usr/local/google/home/mikewallstedt/dev/bigtop_ >>> android/test_proj_poc/project-test/java/com/google/example/test/MainTest.java:3: >>> error: cannot find symbol >>> import com.google.example.Main; >>> ^ >>> symbol: class Main >>> location: package com.google.example >>> /usr/local/google/home/mikewallstedt/dev/bigtop_ >>> android/test_proj_poc/project-test/java/com/google/example/test/MainTest.java:6: >>> error: cannot find symbol >>> private Main main; >>> ^ >>> symbol: class Main >>> location: class MainTest >>> 2 errors >>> :project-test:compileDebugJava FAILED >>> >>> >>> >>> On Monday, July 14, 2014 6:20:49 PM UTC-7, Siva Velusamy wrote: >>> >>>> Could you provide a sample project that demonstrates this issue? Just a >>>> simple "Hello world" app module and an additional test module would do. >>>> >>>> >>>> On Mon, Jul 14, 2014 at 6:08 PM, Michael Wallstedt < >>>> [email protected]> wrote: >>>> >>>>> I have a project with separate modules for several libraries, a >>>>> module for the application, and another module for the tests. In the test >>>>> module, there are references back to the application, which IntelliJ seems >>>>> to handle just find (i.e. ctrl+click takes me where I expect). However, if >>>>> I "make" the test module, there are several errors about missing symbols >>>>> from the application. >>>>> >>>>> I assume that when gradle eventually calls out to javac, the classpath >>>>> is missing a reference to the application source. Could this be because >>>>> the >>>>> application module is generated from the 'com.android.application' plugin, >>>>> as opposed to 'com.android.library'? I suppose I could extract another >>>>> library just for the source that is referenced in tests, and wrap that >>>>> with >>>>> a thin shell to create the actual application, but this seems rather heavy >>>>> handed. Is there a better way? >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "adt-dev" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "adt-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "adt-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
