Package org.sonar.java.checks.helpers
Class UnitTestUtils
- java.lang.Object
-
- org.sonar.java.checks.helpers.UnitTestUtils
-
public final class UnitTestUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static MethodMatchersASSERTION_INVOCATION_MATCHERSstatic PatternASSERTION_METHODS_PATTERNstatic MethodMatchersASSERTIONS_METHOD_MATCHERstatic MethodMatchersCOMMON_ASSERTION_MATCHERMatch when we are sure that the intention is to assert something, that will result in an AssertionError if the assertion fails.static MethodMatchersFAIL_METHOD_MATCHERstatic MethodMatchersREACTIVE_X_TEST_METHODSstatic PatternTEST_METHODS_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanhasJUnit5TestAnnotation(MethodTree tree)static booleanhasNestedAnnotation(ClassTree tree)static booleanhasTestAnnotation(MethodTree tree)static booleanisInUnitTestRelatedToObjectMethods(ExpressionTree expr)static booleanisTestClass(ClassTree classTree)static booleanisUnitTest(MethodTree methodTree)static booleanisUnitTestRelatedToObjectMethods(MethodTree method)
-
-
-
Field Detail
-
ASSERTION_METHODS_PATTERN
public static final Pattern ASSERTION_METHODS_PATTERN
-
TEST_METHODS_PATTERN
public static final Pattern TEST_METHODS_PATTERN
-
ASSERTION_INVOCATION_MATCHERS
public static final MethodMatchers ASSERTION_INVOCATION_MATCHERS
-
REACTIVE_X_TEST_METHODS
public static final MethodMatchers REACTIVE_X_TEST_METHODS
-
FAIL_METHOD_MATCHER
public static final MethodMatchers FAIL_METHOD_MATCHER
-
ASSERTIONS_METHOD_MATCHER
public static final MethodMatchers ASSERTIONS_METHOD_MATCHER
-
COMMON_ASSERTION_MATCHER
public static final MethodMatchers COMMON_ASSERTION_MATCHER
Match when we are sure that the intention is to assert something, that will result in an AssertionError if the assertion fails. The purpose is not to detect any assertion method (similar to S2699).
-
-
Method Detail
-
hasNestedAnnotation
public static boolean hasNestedAnnotation(ClassTree tree)
-
hasTestAnnotation
public static boolean hasTestAnnotation(MethodTree tree)
-
hasJUnit5TestAnnotation
public static boolean hasJUnit5TestAnnotation(MethodTree tree)
-
isInUnitTestRelatedToObjectMethods
public static boolean isInUnitTestRelatedToObjectMethods(ExpressionTree expr)
-
isUnitTestRelatedToObjectMethods
public static boolean isUnitTestRelatedToObjectMethods(@Nullable MethodTree method)
-
isUnitTest
public static boolean isUnitTest(MethodTree methodTree)
-
isTestClass
public static boolean isTestClass(ClassTree classTree)
-
-