Last active
March 13, 2022 06:06
-
-
Save Farhandroid/dc822fd19d9d426c42dd172d5ebbed80 to your computer and use it in GitHub Desktop.
TestDispatchersFunction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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