Timeout parameter

This example shows how to limit the execution time on a junit test. It uses the timeout parameter on @Test by passing in the max number of milliseconds a test has to run. This is helpful if you mix integration tests or have long running tests. When the time limit is exceeded, a failure is triggered by an Exception being thrown.

Timeout parameter

@Test(timeout=100)
public void limit_test_execution_time () {

    //Infinite loop
    while (true) {
    }
}