muthuraj
04/19/2022, 11:59 AMrunTest alternate from runBlocking and I'm facing an issue in testing a specific use case. Here is a simplified version of the test case I want to run.
@Test(expected = NullPointerException::class)
    fun test() = runTest {
        //In my actual code, I'm testing a ViewModel which uses viewModelScope to launch a coroutine
        //and it will throw an exception for a specific case.
        val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
        scope.launch {
            throw NullPointerException("error")
        }
    }muthuraj
04/19/2022, 12:48 PMUnconfinedTestDispatcher as Dispatchers.setMain)