Class TryFailThrowable

java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.TryFailThrowable
All Implemented Interfaces:
BugChecker.TryTreeMatcher, Suppressible, Serializable

public class TryFailThrowable
extends BugChecker
implements BugChecker.TryTreeMatcher
A bug checker for the following code pattern:
 try {
   // do something
   Assert.fail(); // or any Assert.assert*
   // maybe do something more
 } catch (Throwable t) {
   // empty or only comments
 }
 
* Matches all static methods named "fail" and starting with "assert" from the following classes:
  • org.junit.Assert,
  • junit.framework.Assert,
  • junit.framework.TestCase - which overrides the methods from Assert in order to deprecate them and
  • every class whose name ends with "MoreAsserts".
Possible improvements/generalizations of this matcher:
  • support multiple catch() blocks
Author:
adamwos@google.com (Adam Wos)
See Also:
Serialized Form