當前位置: 首頁>>代碼示例>>Java>>正文


Java TestUtils.isJUnitTestMethod方法代碼示例

本文整理匯總了Java中com.siyeh.ig.psiutils.TestUtils.isJUnitTestMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java TestUtils.isJUnitTestMethod方法的具體用法?Java TestUtils.isJUnitTestMethod怎麽用?Java TestUtils.isJUnitTestMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.siyeh.ig.psiutils.TestUtils的用法示例。


在下文中一共展示了TestUtils.isJUnitTestMethod方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (!TestUtils.isJUnitTestMethod(method)) {
    return;
  }
  if (hasExpectedExceptionAnnotation(method)) {
    return;
  }
  if (containsAssertion(method)) {
    return;
  }
  if (lastStatementIsCallToMethodWithAssertion(method)) {
    return;
  }
  registerMethodError(method);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:TestMethodWithoutAssertionInspectionBase.java

示例2: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!TestUtils.isJUnitTestMethod(method)) {
    return;
  }
  final PsiReferenceList throwsList = method.getThrowsList();
  final PsiJavaCodeReferenceElement[] referenceElements =
    throwsList.getReferenceElements();
  if (referenceElements.length < 2) {
    return;
  }

  final Query<PsiReference> query =
    MethodReferencesSearch.search(method);
  final PsiReference firstReference = query.findFirst();
  if (firstReference != null) {
    return;
  }
  registerError(throwsList);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:MultipleExceptionsDeclaredOnTestMethodInspection.java

示例3: satisfiedBy

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiExpressionStatement)) {
    return false;
  }
  final PsiExpressionStatement statement =
    (PsiExpressionStatement)element;
  final PsiExpression expression = statement.getExpression();
  final PsiElement parent = expression.getParent();
  if (!(parent instanceof PsiExpressionStatement)) {
    return false;
  }
  final PsiType type = expression.getType();
  if (!PsiType.BOOLEAN.equals(type)) {
    return false;
  }
  PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
  while (containingMethod != null) {
    if (TestUtils.isJUnitTestMethod(containingMethod)) {
      return true;
    }
    containingMethod = PsiTreeUtil.getParentOfType(containingMethod, PsiMethod.class);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:CreateAssertPredicate.java

示例4: visitClass

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface()
      || aClass.isEnum()
      || aClass.isAnnotationType()
      || aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return;
  }
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  if (!InheritanceUtil.isInheritor(aClass,
                                   "junit.framework.TestCase")) {
    return;
  }
  final PsiMethod[] methods = aClass.getMethods();
  for (final PsiMethod method : methods) {
    if (TestUtils.isJUnitTestMethod(method)) {
      return;
    }
  }
  if (ignoreSupers) {
    final PsiClass superClass = aClass.getSuperClass();
    if (superClass != null) {
      final PsiMethod[] superMethods = superClass.getMethods();
      for (PsiMethod superMethod : superMethods) {
        if (TestUtils.isJUnitTestMethod(superMethod)) {
          return;
        }
      }
    }
  }
  registerClassError(aClass);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:TestCaseWithNoTestMethodsInspection.java

示例5: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (ignoreTestCases) {
    final PsiClass containingClass = method.getContainingClass();
    if (containingClass != null && TestFrameworks.getInstance().isTestClass(containingClass)) {
      return;
    }
    if (TestUtils.isJUnitTestMethod(method)) {
      return;
    }
  }
  if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final PsiReferenceList throwsList = method.getThrowsList();
  final PsiJavaCodeReferenceElement[] references = throwsList.getReferenceElements();
  for (PsiJavaCodeReferenceElement reference : references) {
    final PsiElement element = reference.resolve();
    if (!(element instanceof PsiClass)) {
      continue;
    }
    final PsiClass thrownClass = (PsiClass)element;
    final String qualifiedName = thrownClass.getQualifiedName();
    if (qualifiedName != null && exceptions.contains(qualifiedName)) {
      registerError(reference);
    }
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:30,代碼來源:BadExceptionDeclaredInspection.java

示例6: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (method.isConstructor()) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (containingClass.isInterface() ||
      containingClass.isAnnotationType()) {
    return;
  }
  if (!containingClass.hasModifierProperty(PsiModifier.PUBLIC)) {
    return;
  }
  if (AnnotationUtil.isAnnotated(method, ignorableAnnotations)) {
    return;
  }
  if (onlyWarnIfContainingClassImplementsAnInterface) {
    final PsiClass[] superClasses = containingClass.getSupers();
    boolean implementsInterface = false;
    for (PsiClass superClass : superClasses) {
      if (superClass.isInterface() &&
          !LibraryUtil.classIsInLibrary(superClass)) {
        implementsInterface = true;
        break;
      }
    }
    if (!implementsInterface) {
      return;
    }
  }
  if (exposedInInterface(method)) {
    return;
  }
  if (TestUtils.isJUnitTestMethod(method)) {
    return;
  }
  registerMethodError(method, method);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:52,代碼來源:PublicMethodNotExposedInInterfaceInspectionBase.java


注:本文中的com.siyeh.ig.psiutils.TestUtils.isJUnitTestMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。