I am trying to test that a class that handles some animation change the value of a given object in x
amount of milliseconds.
The test I want to do is "simple"
- check that after
totalAnimationDuration / 2
the current value is bigger than the initial value - check that after
totalAnimationDuration
the value is the one I wanted.
My test looks now something like this:
fun start() {
InstrumentationRegistry.getInstrumentation().runOnMainSync {
val linearAnimation = LinearAnimation()
linearAnimation.start("Name", 0f, 1f, ::setValueTester)
Thread.sleep(2000)
assertEquals(1, currentValue)
}
}
The problem I have if that Thread.sleep(2000)
sleeps the test it self so the complete animation inside start
happens after the sleep
and assert