I'm trying to setup a test project like is described in the Android Testing Blueprint but I receive the following NoClassDefFoundError:
java.lang.NoClassDefFoundError: android.test.mock.MockContentResolver
Android Studio resolves this correctly but when running I receive this error.
It's worth to note that I do not have an androidTest configuration on the app project, instead I only have a separate tests
module with:
apply plugin: 'com.android.test'
I'm running tests like this:
./gradlew :tests:connectedAndroidTest
Test project to reproduce this issue can be found here: https://github.com/vexdev/android-testing-templates/tree/master/AndroidTestingBlueprint
EDIT: Also asked on Android Development community
EDIT: Also created following android issue: https://code.google.com/p/android/issues/detail?id=200182&thanks=200182&ts=1454489567
As @rds said, test package is not part of the framework on the device, therefore you need to include the package.
Seems like com.android.test plugin is not adding those classes, so you can fix it by adding
compile 'com.google.android:android-test:4.1.1.4'
in your dependencies for the module where you are applying the plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With