@@ -0,0 +1,898 @@
+package com.levelup.java.junit;%0A%0Aimport org.junit.Ignore;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.Timeout;%0A%0A/**%0A * This java example will demonstrate how to limit%0A * the execution time on a junit test with a junit rule.%0A * This is helpful if you mix integration test with unit test or if %0A * you have long running tests.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/example/junit-limit-length-of-all-tests/'%3ELimit length of all tests%3C/a%3E%0A * %0A */%0Apublic class TimeoutRule %7B%0A%0A%09//https://github.com/junit-team/junit/wiki/Timeout-for-tests%0A%09%0A%09@Rule public Timeout globalTimeout = new Timeout(100); // 10 seconds max per method tested%0A%0A%09@Ignore(%22Test will always fail%22)%0A%09@Test%0A%09public void infinate_while_loop() %7B%0A%09%09while (true) %7B%0A%09%09%7D%0A%09%7D%0A%0A%09@Ignore(%22Test will always fail%22)%0A%09@Test%0A%09public void infinate_for_loop() %7B%0A%09%09for (;;) %7B%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

add timeout rule example