Hey Guys, I am facing issue regarding mockito test...
# android
Hey Guys, I am facing issue regarding mockito test case for coroutines. It is not executing api call function. Please have a look below code. It is MVP based structure //MVP Structure GlobalScope.launch { // API CALL ON MAIN THREAD val result = //Model return some values GlobalScope.launch(Dispatchers.Main) { when (result) { is APIResult.Success ->(result.response.data) is APIResult.Failure -> parseException(result.details) } } } } Any suggestion?
it might be good to see the test code. Also if you add your code as code snipped it would be better.
Yes sure here is code snipped :
Copy code
lateinit var meuralClient: MeuralAPIContract
    val deviceId = 7L
    val successScheduleApiResult = APIResult.Success(Schedule())

    fun setUp() {
        view = mock()
        meuralClient = mock()
        model = CreateEventModel(mock(), meuralClient)
        device = mock()
        scheduleEvent = ScheduleEvent(0, null, null, null, null, null)
        presenter = CreateEventPresenter(view, model, scheduleEvent, mock(), mock(), mock(), mock())

    fun verifyUpdateSchedule() {
        runBlocking {
            val newSchedule = Schedule()
            whenever(meuralClient.updateDeviceSchedule(deviceId, newSchedule))

            // We are facing an issue at this line.
//            val result = model.updateSchedule(deviceId, newSchedule)
//            assert(result.value?.data == successScheduleApiResult.response.data)
to properly snip your code you should add three grave accent marks: ` at the start and end of your code
lol someone got
user name and had a mention