JUnit - stop it from exiting on finish?

前端 未结 4 645
旧巷少年郎
旧巷少年郎 2021-01-19 22:34

Quick JUnit question. I\'m running some unit tests that involve starting up the GUI and doing a load of stuff.

I would like to see the results after the test to conf

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-19 23:14

    How about using a countdownlatch which you count down.

    private static CountDownLatch countdown = new CountDownLatch(1);

    @AfterClass
    public static void tearDownClass() throws Exception {
        countdown.await();
    }
    

    Then somewhere else in your code you count down latch on event.

    countdown.countDown();
    

    When countdown.countDown() is called then countdown.await() will continue.

提交回复
热议问题