dimanche 27 novembre 2022

Reflection - missing 1 parameter

I am using extention function from this post: https://stackoverflow.com/a/72111931/1305993

In my test I have:

@Before
fun setUp() {
    savedStateHandle = SavedStateHandle()
    savedStateHandle["areaId"] = 1L
    saveImageUseCase = Mockito.mock(SaveImageUseCase::class.java)
    repo = FakeRepository()
    viewModel = AreaEditViewModel(repo, savedStateHandle, saveImageUseCase)
}

@Test
fun setUpArea() = runTest {
    viewModel.callPrivateFunc("setUpArea", 2L)
}

In my viewModel I have:

private suspend fun setUpArea(areaId: Long) {
    repository.getAreaById(areaId).first() {
        savedStateHandle["area"] = it
        true
    }
}

When I run test I get: Callable expects 3 arguments, but 2 were provided. java.lang.IllegalArgumentException: Callable expects 3 arguments, but 2 were provided.

I cannot figure out what is that third parameter missing





Aucun commentaire:

Enregistrer un commentaire