Kamil K
07/01/2024, 1:07 PM@HiltAndroidTest
class CreateNoteScreenKtTest {
@get:Rule(order = 1)
val hiltRule = HiltAndroidRule(this)
@get:Rule(order = 2)
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Before
fun setup() {
hiltRule.inject()
}
@Test
fun validation_message_is_removed_when_performed_input() {
var navBackClicked = false
var toolbarTitle = ""
composeTestRule.setContent {
toolbarTitle = stringResource(id = R.string.create_note_title)
CreateNoteScreen(
viewModel = composeTestRule.activity.viewModels<CreateNoteViewModel>().value,
navigateBack = {
navBackClicked = true
}
)
}
}
This results with java.lang.RuntimeException: Cannot create an instance of class com.todo.ui.createnote.CreateNoteViewModel
Caused by: java.lang.NoSuchMethodException: com.todo.ui.createnote.CreateNoteViewModel.<init> []
Same error if I use hiltViewModel
Any suggestions/materials?