Class JUnit4TearDownNotRun
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.JUnit4TearDownNotRun
- All Implemented Interfaces:
BugChecker.MethodTreeMatcher
,Suppressible
,Serializable
Checks for the existence of a JUnit3 style tearDown() method in a JUnit4 test class or methods
annotated with a non-JUnit4 @After annotation.
- Author:
- glorioso@google.com (Nick Glorioso)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.BlockTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.CaseTreeMatcher, BugChecker.CatchTreeMatcher, BugChecker.ClassTreeMatcher, BugChecker.CompilationUnitTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.ConditionalExpressionTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.DoWhileLoopTreeMatcher, BugChecker.EmptyStatementTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.ExpressionStatementTreeMatcher, BugChecker.ForLoopTreeMatcher, BugChecker.IdentifierTreeMatcher, BugChecker.IfTreeMatcher, BugChecker.ImportTreeMatcher, BugChecker.InstanceOfTreeMatcher, BugChecker.IntersectionTypeTreeMatcher, BugChecker.LabeledStatementTreeMatcher, BugChecker.LambdaExpressionTreeMatcher, BugChecker.LiteralTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MemberSelectTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ModifiersTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<R,
P>, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List
<com.google.errorprone.bugpatterns.AbstractJUnit4InitMethodNotRun.AnnotationReplacements> Returns a collection of 'before-and-after' pairs of annotations that should be replaced on these methods.protected String
Returns the fully qualified class name of the annotation this bugpattern should apply to matched methods.matchMethod
(com.sun.source.tree.MethodTree methodTree, VisitorState state) Matches if all of the following conditions are true: 1) The method matchesmethodMatcher()
, (looks like setUp() or tearDown(), and none of the overrides in the hierarchy of the method have the appropriate @Before or @After annotations) 2) The method is not annotated with @Test 3) The enclosing class has an @RunWith annotation and does not extend TestCase.protected Matcher
<com.sun.source.tree.MethodTree> Returns a matcher that selects which methods this matcher applies to (e.g.Methods inherited from class com.google.errorprone.bugpatterns.BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegions
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.errorprone.matchers.Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
Constructor Details
-
JUnit4TearDownNotRun
public JUnit4TearDownNotRun()
-
-
Method Details
-
methodMatcher
Returns a matcher that selects which methods this matcher applies to (e.g. public void setUp() without @Before/@BeforeClass annotation) -
correctAnnotation
Returns the fully qualified class name of the annotation this bugpattern should apply to matched methods.If another annotation is on the method that has the same name, the import will be replaced with the appropriate one (e.g.: com.example.Before becomes org.junit.Before)
-
annotationReplacements
protected List<com.google.errorprone.bugpatterns.AbstractJUnit4InitMethodNotRun.AnnotationReplacements> annotationReplacements()Returns a collection of 'before-and-after' pairs of annotations that should be replaced on these methods.If this method matcher finds a method annotated with
AbstractJUnit4InitMethodNotRun.AnnotationReplacements.badAnnotation
, instead of applyingcorrectAnnotation()
, instead replace it withAbstractJUnit4InitMethodNotRun.AnnotationReplacements.goodAnnotation
-
matchMethod
Matches if all of the following conditions are true: 1) The method matchesmethodMatcher()
, (looks like setUp() or tearDown(), and none of the overrides in the hierarchy of the method have the appropriate @Before or @After annotations) 2) The method is not annotated with @Test 3) The enclosing class has an @RunWith annotation and does not extend TestCase. This marks that the test is intended to run with JUnit 4.- Specified by:
matchMethod
in interfaceBugChecker.MethodTreeMatcher
-