I'm trying to test a simple method.
I have this class:
class Cloud @Inject constructor(var posx: Double = 0.0, var posy: Double = 0.0, var velocity:
Double = 1.0, val context: Context){
val image: Bitmap = BitmapFactory.decodeResource(context.resources, R.raw.cloud)
fun updateVelocity(){
velocity += 5.0
}
fun draw(canvas: Canvas){
canvas.drawBitmap(image,posx.toFloat() - (image.width / 2),posy.toFloat(),null)
}
}
I want to unit test the updateVelocity() method but i can't figure out how, should i use an instrumental test and pass the context or can i use something like mockk?
Can i do this with mockk?
@Test
fun cloudVelocity() {
val cloud: Cloud = mockk()
//update cloud velocity
//assert that the velocity changed
}