Exception catch coverage support for Thread.sleep

Exception catch coverage is not passed at the thread.sleep location I want to pass it somehow, trial and error If you put sleep before interrupt, it goes into sleep and Exception is thrown.

Test


public class SleepActionTest() {
    @Test
    public void testSleep() throws Exception {
        Thread th = new Thread( ()-> {
            SleepAction.sleep(1000000000);
        });

        th.start();
        TimeUnit.MILLISECONDS.sleep(100);
        th.interrupt();
    }
}

SleepAction


public class SleepAction {
    public static void sleep(int i) {
        try {
            TimeUnit.MILLISECONDS.sleep(i);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Recommended Posts

Exception catch coverage support for Thread.sleep
JMX support for Selenium Grid