Skip to content

Instantly share code, notes, and snippets.

@Farhandroid
Last active March 13, 2022 06:06
Show Gist options
  • Select an option

  • Save Farhandroid/dc822fd19d9d426c42dd172d5ebbed80 to your computer and use it in GitHub Desktop.

Select an option

Save Farhandroid/dc822fd19d9d426c42dd172d5ebbed80 to your computer and use it in GitHub Desktop.
TestDispatchersFunction
class Car {
var fuel = 0
fun addFuel(){
CoroutineScope(Dispatchers.IO).launch {
fuel = 50
}
}
}
class CarTest {
private val car = Car()
@Test
fun addFuel() = runTest{
car.addFuel()
Assert.assertEquals(50,car.fuel)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment