当前位置: 首页>>代码示例>>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;未经允许,请勿转载。