Reputation: 19415
I am trying to write a Robolectric test. I was following few tutorials where they seem to be using
@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)
to setup the test, but in my case The parameter constants does not seem to resolve.
My Robolectric dependency looks like this:
testImplementation "org.robolectric:robolectric:4.0.2"
Upvotes: 21
Views: 4717
Reputation: 728
constants
parameter is now deprecated see the doc :
constants
Deprecated.
If you are using at least Android Studio 3.0 alpha 5 please migrate to the
preferred way to configure builds for Gradle with AGP3.0
http://robolectric.org/getting-started/
The proper way to set up Robolectric per the documentation is :
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
testImplementation 'org.robolectric:robolectric:4.1'
}
Upvotes: 19
Reputation: 12583
Robolectric is for unit
test, not for androidTest
, so please confirm that your test case is under src/test
, NOT under src/androidTest
.
Upvotes: 0