Class TestRuleLimitSysouts

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class TestRuleLimitSysouts
    extends com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
    This test rule serves two purposes:
    • it fails the test if it prints too much to stdout and stderr (tests that chatter too much are discouraged)
    • the rule ensures an absolute hard limit of stuff written to stdout and stderr to prevent accidental infinite loops from filling all available disk space with persisted output.
    The rule is not enforced for certain test types (see isEnforced()).
    • Constructor Detail

    • Method Detail

      • before

        protected void before()
                       throws Throwable
        Overrides:
        before in class com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
        Throws:
        Throwable
      • checkCaptureStreams

        public static void checkCaptureStreams()
        Ensures System.out and System.err point to delegate streams.
      • isEnforced

        protected boolean isEnforced()
      • afterIfSuccessful

        protected void afterIfSuccessful()
                                  throws Throwable
        We're only interested in failing the suite if it was successful (otherwise just propagate the original problem and don't bother doing anything else).
        Overrides:
        afterIfSuccessful in class com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
        Throws:
        Throwable
      • afterAlways

        protected void afterAlways​(List<Throwable> errors)
                            throws Throwable
        Overrides:
        afterAlways in class com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
        Throws:
        Throwable