He
12/03/2022, 12:22 AMfun wait(){
val timeout= TimeHelper.getNow() + timeoutInterval // <- part of class constructor
if(processor.getLag() > 0){
val currentTIme = TimeHelper.getNow()
if(currentTime >= timeout){ System.exit(42) }
Thread.sleep(someTime)
}
}
Is there a way for me to use mockk to either that wait()
has executed for x amount of time with verify(exactly = x) { someProcessor.wait() }
, or Thread.sleep()
has been sleeping for x number of time?
I have something like this in my test class
every { processor.getLag() } returns 1
every { TimeHelper.getNow() } returns 100
So after some number of executions ever{ processor.getLag() } returns 0
to validate that it finishesMattia Tommasone
12/03/2022, 9:45 AMrunBlocking
and delay
rather than Thread.sleep()
that way, by using runBlockingTest
in your test you can test the rest of your code without the delays