|
5 | 5 | import static org.junit.Assume.assumeNoException;
|
6 | 6 | import static org.junit.Assume.assumeNotNull;
|
7 | 7 | import static org.junit.Assume.assumeThat;
|
| 8 | +import static org.junit.Assume.assumeTrue; |
| 9 | +import static org.junit.experimental.results.PrintableResult.testResult; |
| 10 | +import static org.junit.experimental.results.ResultMatchers.isSuccessful; |
8 | 11 | import static org.junit.matchers.StringContains.containsString;
|
9 | 12 |
|
10 | 13 | import org.junit.Assume;
|
| 14 | +import org.junit.Before; |
| 15 | +import org.junit.BeforeClass; |
11 | 16 | import org.junit.Test;
|
12 | 17 | import org.junit.Assume.AssumptionViolatedException;
|
13 | 18 | import org.junit.runner.JUnitCore;
|
@@ -106,4 +111,32 @@ private void assertCompletesNormally() {
|
106 | 111 | @Test(expected=AssumptionViolatedException.class) public void assumeTrueWorks() {
|
107 | 112 | Assume.assumeTrue(false);
|
108 | 113 | }
|
| 114 | + |
| 115 | + public static class HasFailingAssumeInBefore { |
| 116 | + @Before public void checkForSomethingThatIsntThere() { |
| 117 | + assumeTrue(false); |
| 118 | + } |
| 119 | + |
| 120 | + @Test public void failing() { |
| 121 | + fail(); |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + @Test public void failingAssumptionInBeforePreventsTestRun() { |
| 126 | + assertThat(testResult(HasFailingAssumeInBefore.class), isSuccessful()); |
| 127 | + } |
| 128 | + |
| 129 | + public static class HasFailingAssumeInBeforeClass { |
| 130 | + @BeforeClass public static void checkForSomethingThatIsntThere() { |
| 131 | + assumeTrue(false); |
| 132 | + } |
| 133 | + |
| 134 | + @Test public void failing() { |
| 135 | + fail(); |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + @Test public void failingAssumptionInBeforeClassPreventsTestRun() { |
| 140 | + assertThat(testResult(HasFailingAssumeInBeforeClass.class), isSuccessful()); |
| 141 | + } |
109 | 142 | }
|
0 commit comments