Skip to content

Instantly share code, notes, and snippets.

@desseim
Last active August 29, 2015 14:05
Show Gist options
  • Save desseim/0ea3438ea99c8a6e8a77 to your computer and use it in GitHub Desktop.
Save desseim/0ea3438ea99c8a6e8a77 to your computer and use it in GitHub Desktop.
Gradle dependency configuration for injected tests using mockito, dagger, guava and auto with Android

This is the configuration I used to get the tests for my Android project to run. This works with Android Studio 0.8 (Gradle 1.12).

The project uses notably guava, mockito, dagger, assertj, awaitility, auto, retrofit / okhttp and mockwebserver and also needs to inject some tests with test-specific modules. Given the necessity to inject tests and the current lack of support for transitive dependencies for the androidTestXxx scopes, the dependency settings are somewhat tricky to get to work properly.

compile 'com.android.support:appcompat-v7:20'
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.3'
compile 'javax.inject:javax.inject:1@jar'
compile 'de.greenrobot:eventbus:2.2.1@jar'
compile 'com.netflix.rxjava:rxjava-core:0.20.2'
compile 'com.netflix.rxjava:rxjava-android:0.20.2'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.jayway.awaitility:awaitility:1.6.1'
compile 'com.github.frankiesardo:auto-parcel:0.2'

apt 'com.squareup.dagger:dagger-compiler:1.2.2'
apt 'com.github.frankiesardo:auto-parcel-processor:0.2'

// dependencies for tests
androidTestCompile 'org.assertj:assertj-core:1.6.1'
androidTestCompile('org.assertj:assertj-guava:1.2.0') {
    exclude module: 'guava'
}
androidTestCompile 'org.skyscreamer:jsonassert:1.2.3'
androidTestCompile('com.squareup.okhttp:mockwebserver:2.0.+') {
    exclude module: 'okhttp'
}
androidTestCompile('org.mockito:mockito-core:1.9.5') {
    exclude group: 'org.hamcrest'
}
androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.1') {
    exclude group: 'org.mockito'
}
androidTestApt 'com.squareup.dagger:dagger-compiler:1.2.2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment