JUnit5用户手册~超时

参数值 等价的注解
42
@Timeout(42)
42 ns
@Timeout(value = 42, unit = NANOSECONDS)
42 μ s
@Timeout(value = 42, unit = MICROSECONDS)
42 ms
@Timeout(value = 42, unit = MILLISECONDS)
42 s
@Timeout(value = 42, unit = SECONDS)
42 m
@Timeout(value = 42, unit = MINUTES)
42 h
@Timeout(value = 42, unit = HOURS)
42 d
@Timeout(value = 42, unit = DAYS)

1、轮询超时测试

@Test
@Timeout(5) // Poll at most 5 seconds
void pollUntil() throws InterruptedException {
  while (asynchronousResultNotAvailable()) {
  Thread.sleep(250); // custom poll interval
  }
  // Obtain the asynchronous result and perform assertions
}

你可能感兴趣的:(单元测试,Java,服务器,spring,boot,junit)