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


Java TestUtils.isJUnit4TestMethod方法代碼示例

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


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

示例1: buildFixes

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
  final List<InspectionGadgetsFix> fixes = new ArrayList(3);
  final PsiMethod method = (PsiMethod)infos[1];
  if (AnnotationUtil.isAnnotated(method, IGNORE, false)) {
    fixes.add(new RemoveIgnoreAndRename(method));
  }
  if (TestUtils.isJUnit4TestMethod(method)) {
    String methodName = method.getName();
    String newMethodName;
    if (methodName.startsWith("test")) {
      newMethodName = null;
    }
    else {
      boolean lowCaseStyle = methodName.contains("_");
      newMethodName = "test" + (lowCaseStyle ? "_" + methodName : StringUtil.capitalize(methodName));
    }
    fixes.add(new RemoveTestAnnotationFix(newMethodName));
  }
  final PsiClass aClass = (PsiClass)infos[0];
  final String className = aClass.getName();
  fixes.add(new ConvertToJUnit4Fix(className));
  return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java

示例2: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final String name = method.getName();
  if (!name.startsWith("test")) {
    return;
  }
  if (!TestUtils.isRunnable(method)) {
    return;
  }
  if (TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (TestUtils.isJUnitTestClass(containingClass)) {
    return;
  }
  if (!containsJUnit4Annotation(containingClass)) {
    return;
  }
  registerMethodError(method);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:JUnit3StyleTestMethodInJUnit4ClassInspection.java

示例3: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (!TestUtils.isJUnitTestClass(containingClass)) {
    return;
  }

  if (AnnotationUtil.isAnnotated(containingClass, TestUtils.RUN_WITH, true)) {
    return;
  }

  if (AnnotationUtil.isAnnotated(method, IGNORE, false) && method.getName().startsWith("test")) {
    registerMethodError(method, containingClass, method);
  } else if (TestUtils.isJUnit4TestMethod(method)) {
    registerMethodError(method, containingClass, method);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:JUnit4AnnotatedMethodInJUnit3TestCaseInspectionBase.java

示例4: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!TestUtils.isJUnit4TestMethod(method) || !TestUtils.isRunnable(method)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:JUnit4MethodNamingConventionInspectionBase.java

示例5: buildFixes

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
  final List<InspectionGadgetsFix> fixes = new ArrayList(3);
  final PsiMethod method = (PsiMethod)infos[1];
  if (AnnotationUtil.isAnnotated(method, IGNORE, false)) {
    fixes.add(new RemoveIgnoreAndRename(method));
  }
  if (TestUtils.isJUnit4TestMethod(method)) {
    fixes.add(new RemoveTestAnnotationFix());
  }
  final PsiClass aClass = (PsiClass)infos[0];
  final String className = aClass.getName();
  fixes.add(new ConvertToJUnit4Fix(className));
  return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:17,代碼來源:JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java

示例6: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (!TestUtils.isJUnitTestClass(containingClass)) {
    return;
  }
  if (AnnotationUtil.isAnnotated(method, IGNORE, false) && method.getName().startsWith("test")) {
    registerMethodError(method, containingClass, method);
  } else if (TestUtils.isJUnit4TestMethod(method)) {
    registerMethodError(method, containingClass, method);
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:17,代碼來源:JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java

示例7: hasJUnit4TestMethods

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
private boolean hasJUnit4TestMethods(@NotNull PsiClass aClass) {
  //use this if this method turns out to have bad performance:
  //if (!TestUtils.isTest(aClass)) {
  //    return false;
  //}
  final PsiMethod[] methods = aClass.getMethods();
  for (PsiMethod method : methods) {
    if (TestUtils.isJUnit4TestMethod(method)) {
      return true;
    }
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:JUnitTestClassNamingConventionInspectionBase.java

示例8: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  final PsiClass containingClass = method.getContainingClass();
  if (TestUtils.isInTestSourceContent(containingClass) ||
      !TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  registerMethodError(method);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:TestMethodInProductCodeInspection.java

示例9: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //note: no call to super;
  if (method.isConstructor()) {
    return;
  }
  if (!TestUtils.isJUnit3TestMethod(method) && !TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  final PsiParameterList parameterList = method.getParameterList();
  final boolean takesArguments;
  final boolean isStatic;
  if (parameterList.getParametersCount() == 0) {
    takesArguments = false;
    isStatic = method.hasModifierProperty(PsiModifier.STATIC);
    if (!isStatic && PsiType.VOID.equals(returnType) && method.hasModifierProperty(PsiModifier.PUBLIC)) {
      return;
    }
  }
  else {
    isStatic = false;
    takesArguments = true;
  }
  registerMethodError(method, Boolean.valueOf(takesArguments),
                      Boolean.valueOf(isStatic));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:TestMethodIsPublicVoidNoArgInspection.java

示例10: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.NATIVE) && isInspectionEnabled("NativeMethodNamingConvention", method)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  if (TestUtils.isRunnable(method)) {
    if (TestUtils.isJUnit4TestMethod(method) && isInspectionEnabled("JUnit4MethodNamingConvention", method)) {
      return;
    }
    if (TestUtils.isJUnit3TestMethod(method) && isInspectionEnabled("JUnit3MethodNamingConvention", method)) {
      return;
    }
  }
  if (isTestNGTestMethod(method) && isInspectionEnabled("TestNGMethodNamingConvention", method)) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:37,代碼來源:InstanceMethodNamingConventionInspectionBase.java

示例11: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final String name = method.getName();
  if (!name.startsWith("test")) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.ABSTRACT) || !method.hasModifierProperty(PsiModifier.PUBLIC)) {
    return;
  }
  if (TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  if (returnType == null || !returnType.equals(PsiType.VOID)) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 0) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (TestUtils.isJUnitTestClass(containingClass)) {
    return;
  }
  if (!containsReferenceToClass(containingClass, "org.junit.Test")) {
    return;
  }
  registerMethodError(method);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:31,代碼來源:JUnit3StyleTestMethodInJUnit4ClassInspection.java

示例12: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(PsiMethod method) {
  final PsiClass containingClass = method.getContainingClass();
  if (TestUtils.isTest(containingClass) ||
      !TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  registerMethodError(method);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:10,代碼來源:TestMethodInProductCodeInspection.java

示例13: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //導入方法依賴的package包/類
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //note: no call to super;
  @NonNls final String methodName = method.getName();
  if (!methodName.startsWith("test") &&
      !TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  if (returnType == null) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  final boolean takesArguments;
  final boolean isStatic;
  if (parameterList.getParametersCount() == 0) {
    takesArguments = false;
    isStatic = method.hasModifierProperty(PsiModifier.STATIC);
    if (!isStatic && returnType.equals(PsiType.VOID) &&
        method.hasModifierProperty(PsiModifier.PUBLIC)) {
      return;
    }
  }
  else {
    isStatic = false;
    takesArguments = true;
  }
  final PsiClass targetClass = method.getContainingClass();
  if (!AnnotationUtil.isAnnotated(method, "org.junit.Test", true)) {
    if (targetClass == null ||
        !InheritanceUtil.isInheritor(targetClass,
                                     "junit.framework.TestCase")) {
      return;
    }
  }
  registerMethodError(method, Boolean.valueOf(takesArguments),
                      Boolean.valueOf(isStatic));
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:39,代碼來源:TestMethodIsPublicVoidNoArgInspection.java


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