dependencies is not a property of sourceSets. It's a global DSL object on
the project, so doing it inside sourceSets won't help.

What is going on with the runtime part after that anyway? there is no
buildType called 'test', and again, since dependencies is not a property of
sourcesets, I'm not even sure what it's doing (there's no 'runtime'
 configuration object anyway, so this really cannot work).

So really you should be able to just do

dependencies {
  androidTestCompile '...'
}

What does JMock do? If it's like Mockito where it create classes on the
fly, it may not work on Android (Mockito has special android support
through dexmaker)



On Thu, Apr 3, 2014 at 4:58 AM, Sandesh <[email protected]> wrote:

> Hi,
>
> As part of my app Unit testing code, I am using JMock for mocking
> dependent objects for my SUT (class under test) in my Test Application. I
> am using Gradle build to build my app. I have defined the 'JMock'
> dependency using 'androidTestCompile'. The Test app. code is being compiled
> fine, but when I try to execute the Test app, it gives
> 'ClassNotFoundException' for JMock classes.
>
> I tried to dynamically package the JMock dependency as part of the Test
> app APK file, using 'runtime' scope for the dependency, but it did not help.
>
> The question I have is, how do I package these Testing jar dependencies,
> to my Test APK using the dependency code. I am listing relevant excerpts
> from build.gradle file:
>
> .....
> android {
>      .....
>      sourceSets {
>           ....
>           dependencies {
>                 androidTestCompile 'org.jmock:jmock:2.6.0'
>           }
>      }
>
>     ..........
>
>      applicationVariants.all { appVariant ->
>         if (appVariant.buildType.name.contains('test')) {
>             appVariant.sourceSet.dependencies << {
>                 runtime 'org.jmock:jmock:2.6.0'
>             }
>         }
>     }
>     ........
> }
>
> Any help is greatly appreciated.
>
> Regards,
> Sandesh.
>
> --
> 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.
>



-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

-- 
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.

Reply via email to