java-test-examples

  • junit4
  • Jupiter / JUnit 5
  • testng
  • spring-boot-test
  • jmh(Java Micro-benchmark Harness)
  • testcontainers

junit4

Jupiter / JUnit 5

testcontainers

awaitility

junit异步测试时,现在是用Thread.sleep(...)CountDownLatch的方式阻止测试方法退出。 awaitility相对可能更友好一点。

Awaitility.await().atMost(1, TimeUnit.MINUTES)
        .untilAsserted(() -> Assertions.assertEquals(msgSize, msgCounter.get()));

see: