How can I get a string resource in an instrumented test without using
createAndroidComposeRule()
?
I do not want or need to load my app’s main activity. That would load all of my application content, and this is a Unit Test for a single composable. But I need to get a string resource to test with.
Bradleycorn
02/20/2022, 11:30 PM
For now I’m doing this. It seems to work. 🤷
Copy code
val context = ApplicationProvider.getApplicationContext<Application>()
val contentDescription = context.getString(R.string.my_button_description)
composeRule.onNodeWithContentDescription(contentDescription).assertIsDisplayed()
a
allan.conda
02/21/2022, 1:14 AM
Yeah, that one. Or get the context from setContent using a var