### Question:
DisableOnDebug implements TestRule { private static boolean isDebugging(List<String> arguments) { for (final String argument : arguments) { if ("-Xdebug".equals(argument)) { return true; } else if (argument.startsWith("-agentlib:jdwp")) { return true; } } return false; } DisableOnDebug(TestRule rule);   DisableOnDebug(TestRule rule, List<String> inputArguments); Statement apply(Statement base, Description description); boolean isDebugging();  }### Answer:
@Test public void givenPreJava5DebugArgumentsIsDebuggingShouldReturnTrue() { DisableOnDebug subject = new DisableOnDebug( new FailOnExecution(), PRE_JAVA5_DEBUG_ARGUMENTS); assertTrue("Should be debugging", subject.isDebugging()); }
@Test public void givenPreJava5DebugArgumentsInReverseIsDebuggingShouldReturnTrue() { DisableOnDebug subject = new DisableOnDebug( new FailOnExecution(), PRE_JAVA5_DEBUG_ARGUMENTS_IN_REVERSE_ORDER); assertTrue("Should be debugging", subject.isDebugging()); }
@Test public void givenPostJava5DebugArgumentsIsDebuggingShouldReturnTrue() { DisableOnDebug subject = new DisableOnDebug( new FailOnExecution(), POST_JAVA5_DEBUG_ARGUMENTS); assertTrue("Should be debugging", subject.isDebugging()); }
@Test public void givenArgumentsWithoutDebugFlagsIsDebuggingShouldReturnFalse() { DisableOnDebug subject = new DisableOnDebug( new FailOnExecution(), WITHOUT_DEBUG_ARGUMENTS); Assert.assertFalse("Should not be debugging", subject.isDebugging()); }