Class SpringFailOnTimeout

java.lang.Object
org.junit.runners.model.Statement
org.springframework.test.context.junit4.statements.SpringFailOnTimeout

public class SpringFailOnTimeout extends Statement
SpringFailOnTimeout is a custom JUnit Statement which adds support for Spring's @Timed annotation by throwing an exception if the next statement in the execution chain takes more than the specified number of milliseconds.

In contrast to JUnit's FailOnTimeout, the next statement will be executed in the same thread as the caller and will therefore not be aborted preemptively.

Since:
3.0
Author:
Sam Brannen
See Also:
  • Constructor Details

    • SpringFailOnTimeout

      public SpringFailOnTimeout(Statement next, Method testMethod)
      Construct a new SpringFailOnTimeout statement for the supplied testMethod, retrieving the configured timeout from the @Timed annotation on the supplied method.
      Parameters:
      next - the next Statement in the execution chain
      testMethod - the current test method
      See Also:
    • SpringFailOnTimeout

      public SpringFailOnTimeout(Statement next, long timeout)
      Construct a new SpringFailOnTimeout statement for the supplied timeout.

      If the supplied timeout is 0, the execution of the next statement will not be timed.

      Parameters:
      next - the next Statement in the execution chain; never null
      timeout - the configured timeout for the current test, in milliseconds; never negative
  • Method Details