Class Timeout.Builder

  • Enclosing class:
    Timeout

    public static class Timeout.Builder
    extends java.lang.Object
    Builder for Timeout.
    Since:
    4.12
    • Field Detail

      • lookForStuckThread

        private boolean lookForStuckThread
      • timeout

        private long timeout
      • timeUnit

        private java.util.concurrent.TimeUnit timeUnit
    • Constructor Detail

      • Builder

        protected Builder()
    • Method Detail

      • withTimeout

        public Timeout.Builder withTimeout​(long timeout,
                                           java.util.concurrent.TimeUnit unit)
        Specifies the time to wait before timing out the test.

        If this is not called, or is called with a timeout of 0, the returned Timeout rule instance will cause the tests to wait forever to complete, however the tests will still launch from a separate thread. This can be useful for disabling timeouts in environments where they are dynamically set based on some property.

        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        this for method chaining.
      • getTimeout

        protected long getTimeout()
      • getTimeUnit

        protected java.util.concurrent.TimeUnit getTimeUnit()
      • withLookingForStuckThread

        public Timeout.Builder withLookingForStuckThread​(boolean enable)
        Specifies whether to look for a stuck thread. If a timeout occurs and this feature is enabled, the rule will look for a thread that appears to be stuck and dump its backtrace. This feature is experimental. Behavior may change after the 4.12 release in response to feedback.
        Parameters:
        enable - true to enable the feature
        Returns:
        this for method chaining.
      • getLookingForStuckThread

        protected boolean getLookingForStuckThread()
      • build

        public Timeout build()
        Builds a Timeout instance using the values in this builder.,