Skip to content

Commit

Permalink
add delay to test unit
Browse files Browse the repository at this point in the history
  • Loading branch information
jinliu9508 committed Jun 25, 2024
1 parent a23b921 commit afdfdc4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class StartupServiceTests : FunSpec({
verify(exactly = 0) { mockBootstrapService2.bootstrap() }
}

test("startup will call all IStartableService dependencies successfully") {
test("startup will call all IStartableService dependencies successfully after a short delay") {
// Given
val mockStartupService1 = spyk<IStartableService>()
val mockStartupService2 = spyk<IStartableService>()
Expand All @@ -88,6 +88,7 @@ class StartupServiceTests : FunSpec({
startupService.scheduleStart()

// Then
Thread.sleep(10)
verify(exactly = 1) { mockStartupService1.start() }
verify(exactly = 1) { mockStartupService2.start() }
}
Expand All @@ -105,6 +106,7 @@ class StartupServiceTests : FunSpec({
mockStartableService3.start()

// Then
Thread.sleep(10)
coVerifyOrder {
// service3 will call start() first even though service1 and service2 are scheduled first
mockStartableService3.start()
Expand Down

0 comments on commit afdfdc4

Please sign in to comment.