All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.junit.rules.Timeout Maven / Gradle / Ivy

package org.junit.rules;

import org.junit.internal.runners.statements.FailOnTimeout;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

/**
 * The Timeout Rule applies the same timeout to all test methods in a class:
 *
 * 
 * public static class HasGlobalTimeout {
 *  public static String log;
 *
 *  @Rule
 *  public Timeout globalTimeout= new Timeout(20);
 *
 *  @Test
 *  public void testInfiniteLoop1() {
 *      log+= "ran1";
 *      for (;;) {
 *         }
 *     }
 *
 *  @Test
 *  public void testInfiniteLoop2() {
 *      log+= "ran2";
 *      for (;;) {
 *         }
 *     }
 * }
 * 
* * @since 4.7 */ public class Timeout implements TestRule { private final int fMillis; /** * @param millis the millisecond timeout */ public Timeout(int millis) { fMillis = millis; } public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, fMillis); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy