I have a MainActivity written in Kotlin. I can run the setupActivity in kotlin like so:
@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)
class MyActivityTestKotlin {
@Before
public fun setup() {
Robolectric.setupActivity(MainActivity::class.java)
}
}
However, when I write the test in java, I get the error:
android.content.res.Resources$NotFoundException: String resource ID #0x7f0c001f
Java code:
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class MyActivityTest {
@Before
public void setup() {
setupActivity(MainActivity.class);
}
}
Is it possible to write the tests in java for such cases?Thanks!!
Add in the gradel unit test option for resource to access compiled resources during testing
testOptions {
unitTests {
includeAndroidResources = true
}
}
RoboElectric docs
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