When running Robolectric unit tests with the latest version of Compose 1.2.0, then the tests using createAndroidComposeRule fail with the following error:
MyActivity has already set content. If you have populated the Activity with a ComposeView, make sure to call setContent on that ComposeView instead of on the test rule; and make sure that that call to
setContent {}is done after the ComposeTestRule has run
Code from one of the failing tests:
composeTestRule.setContent {
Column {
Text(textTitle)
DemoScopedInjectedViewModelComposable()
}
}