Thread.sleep している箇所で Exception catch のカバレッジが通っていない
どうにか通したいと思い試行錯誤
interrupt の前に sleep 入れたら sleep に入って、Exception 発生するようになった
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();
}
}
}