Created
April 1, 2014 22:10
-
-
Save kroepke/9924153 to your computer and use it in GitHub Desktop.
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
private final Set<AssertionError> assertionErrors = Sets.newHashSet(); | |
@BeforeTest | |
public void assertErrorTrap() { | |
assertionErrors.clear(); | |
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | |
@Override | |
public void uncaughtException(Thread t, Throwable e) { | |
if (e instanceof AssertionError) { | |
assertionErrors.add((AssertionError) e); | |
} | |
} | |
}); | |
} | |
@AfterTest | |
public void checkThreadAssertions() { | |
assertEquals(assertionErrors.size(), 0, "Background threads should not fail assertions"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment