Class UnitTestUtils

java.lang.Object
org.sonar.java.checks.helpers.UnitTestUtils

public final class UnitTestUtils extends Object
  • Field Details

    • ASSERTION_METHODS_PATTERN

      public static final Pattern ASSERTION_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 Details

    • 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)
    • methodNameMatchesAssertionMethodPattern

      public static boolean methodNameMatchesAssertionMethodPattern(String methodName, Symbol methodSymbol)