3

PS: Codes in Kotlin

In my unit test,

I have mutable list of string called slot

val slot = mutableListOf<String>()

I captured this slot list

every { someService.whateverMethod(capture(slot)) } just Runs

In the end of certain test I check size of slot.

slot.size shouldBe 2

A method that I test contains asynchronous operations. Accordingly, I should write Thread.sleep(1000) before checking slot size (slot.size shouldBe 2)

How to refuse Thread.sleep(1000) operation, and make something that will wait for 1 second. Something like verify(timeout = 10000).

Seydazimov Nurbol
  • 1,404
  • 3
  • 10
  • 25

0 Answers0