Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TestWatcher.skipped(): Make test fail

To show problem of skipped not ignoring failures in skipped-method here is the test - which fails.
  • Loading branch information...
commit a982920ee8036d001aa4a223a2521be28681ec27 1 parent 129a5f7
Mark Michaelis authored
24 src/test/java/org/junit/tests/experimental/rules/TestWatcherTest.java
View
@@ -10,6 +10,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.results.PrintableResult;
+import org.junit.internal.AssumptionViolatedException;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
@@ -35,6 +36,29 @@ public void neitherLogSuccessNorFailedForViolatedAssumption() {
is("starting finished "));
}
+ public static class TestWatcherSkippedThrowsExceptionTest {
+ @Rule
+ public TestRule watcher= new TestWatcher() {
+ @Override
+ protected void skipped(AssumptionViolatedException e, Description description) {
+ throw new RuntimeException("watcher failure");
+ }
+ };
+
+ @Test
+ public void fails() {
+ throw new AssumptionViolatedException("test failure");
+ }
+ }
+
+ @Test
+ public void testWatcherSkippedThrowsException() {
+ PrintableResult result= testResult(TestWatcherSkippedThrowsExceptionTest.class);
+ assertThat(result, failureCountIs(2));
+ assertThat(result, hasFailureContaining("test failure"));
+ assertThat(result, hasFailureContaining("watcher failure"));
+ }
+
public static class FailingTest {
private static StringBuilder watchedLog= new StringBuilder();
Please sign in to comment.
Something went wrong with that request. Please try again.