-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes gh-121 (ExpectedException handles JUnit exceptions)
ExpectedException rule no longer handles AssertionErrors and AssumptionViolatedExceptions by default. This means that the rule doesn't intercept if your test fails because of an violated assertion or assumption. If you want to test assertions or assumptions you have to tell the rule to handle such exceptions via handleAssertionErrors() or handleAssumptionViolatedExceptions().
- Loading branch information
1 parent
2d13004
commit 128553f
Showing
6 changed files
with
622 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/org/junit/runner/notification/EventCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.junit.runner.notification; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.runner.Description; | ||
import org.junit.runner.Result; | ||
|
||
public class EventCollector extends RunListener { | ||
private final List<Description> testRunsStarted= new ArrayList<Description>(); | ||
|
||
private final List<Result> testRunsFinished= new ArrayList<Result>(); | ||
|
||
private final List<Description> testsStarted= new ArrayList<Description>(); | ||
|
||
private final List<Description> testsFinished= new ArrayList<Description>(); | ||
|
||
private final List<Failure> failures= new ArrayList<Failure>(); | ||
|
||
private final List<Failure> violatedAssumptions= new ArrayList<Failure>(); | ||
|
||
private final List<Description> testsIgnored= new ArrayList<Description>(); | ||
|
||
@Override | ||
public void testRunStarted(Description description) throws Exception { | ||
testRunsStarted.add(description); | ||
} | ||
|
||
@Override | ||
public void testRunFinished(Result result) throws Exception { | ||
testRunsFinished.add(result); | ||
} | ||
|
||
@Override | ||
public void testStarted(Description description) throws Exception { | ||
testsStarted.add(description); | ||
} | ||
|
||
@Override | ||
public void testFinished(Description description) throws Exception { | ||
testsFinished.add(description); | ||
} | ||
|
||
@Override | ||
public void testFailure(Failure failure) throws Exception { | ||
failures.add(failure); | ||
} | ||
|
||
@Override | ||
public void testAssumptionFailure(Failure failure) { | ||
violatedAssumptions.add(failure); | ||
} | ||
|
||
@Override | ||
public void testIgnored(Description description) throws Exception { | ||
testsIgnored.add(description); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.