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"
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'
}
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