Skip to content

Commit

Permalink
fix AssumptionTests
Browse files Browse the repository at this point in the history
In case a test is expecting AssumptionViolatedException by using the attribute 'expected' of the @test annotation,
the test will actually be marked as skipped by IDEA and mvn, as if the AssumptionViolatedException had been thrown up in the stack.

See issue junit-team#1290
  • Loading branch information
alb-i986 committed May 12, 2016
1 parent 98bbacd commit 6413e99
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/test/java/org/junit/tests/experimental/AssumptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ public void passingAssumptionsScootThrough() {
assertThat(result.getFailureCount(), is(1));
}

@Test(expected = AssumptionViolatedException.class)
@Test
public void assumeThatWorks() {
assumeThat(1, is(2));
try {
assumeThat(1, is(2));
fail("should throw AssumptionViolatedException");
} catch (AssumptionViolatedException e) {
// expected
}
}

@Test
Expand All @@ -94,10 +99,15 @@ public void assumeThatPassesOnStrings() {
assertCompletesNormally();
}

@Test(expected = AssumptionViolatedException.class)
@Test
public void assumeNotNullThrowsException() {
Object[] objects = {1, 2, null};
assumeNotNull(objects);
try {
Object[] objects = {1, 2, null};
assumeNotNull(objects);
fail("should throw AssumptionViolatedException");
} catch (AssumptionViolatedException e) {
// expected
}
}

@Test
Expand Down Expand Up @@ -133,9 +143,14 @@ public void assumeNoExceptionThrows() {
private void assertCompletesNormally() {
}

@Test(expected = AssumptionViolatedException.class)
@Test
public void assumeTrueWorks() {
Assume.assumeTrue(false);
try {
Assume.assumeTrue(false);
fail("should throw AssumptionViolatedException");
} catch (AssumptionViolatedException e) {
// expected
}
}

public static class HasFailingAssumeInBefore {
Expand Down

0 comments on commit 6413e99

Please sign in to comment.