本文整理汇总了Java中com.siyeh.ig.psiutils.TestUtils类的典型用法代码示例。如果您正苦于以下问题:Java TestUtils类的具体用法?Java TestUtils怎么用?Java TestUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestUtils类属于com.siyeh.ig.psiutils包,在下文中一共展示了TestUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: visitMethod
import com.siyeh.ig.psiutils.TestUtils; //导入依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
if (!TestUtils.isJUnit3TestMethod(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,代码来源:JUnit3MethodNamingConventionInspectionBase.java
示例6: 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
示例7: 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
示例8: 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;
}
示例9: 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
示例10: 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
示例11: build
import com.siyeh.ig.psiutils.TestUtils; //导入依赖的package包/类
@Nullable
public static SuppressForTestsScopeFix build(BaseInspection inspection, PsiElement context) {
if (!TestUtils.isInTestSourceContent(context)) {
return null;
}
return new SuppressForTestsScopeFix(inspection);
}
示例12: visitMethod
import com.siyeh.ig.psiutils.TestUtils; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
//note: no call to super;
if (!TestUtils.isJUnit4BeforeClassOrAfterClassMethod(method)) {
return;
}
final PsiType returnType = method.getReturnType();
if (returnType == null) {
return;
}
final PsiClass targetClass = method.getContainingClass();
if (targetClass == null) {
return;
}
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() != 0 ||
!returnType.equals(PsiType.VOID) ||
!method.hasModifierProperty(PsiModifier.PUBLIC) ||
!method.hasModifierProperty(PsiModifier.STATIC)) {
registerMethodError(method, "Change signature of \'" +
PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY,
PsiFormatUtil.SHOW_NAME |
PsiFormatUtil.SHOW_MODIFIERS |
PsiFormatUtil.SHOW_PARAMETERS |
PsiFormatUtil.SHOW_TYPE,
PsiFormatUtil.SHOW_TYPE) +
"\' to \'public static void " +
method.getName() +
"()\'");
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspectionBase.java
示例13: visitMethod
import com.siyeh.ig.psiutils.TestUtils; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
if (!method.isConstructor()) {
return;
}
final PsiClass aClass = method.getContainingClass();
if (!TestUtils.isJUnitTestClass(aClass) && !TestUtils.isJUnit4TestClass(aClass, false)) {
return;
}
if (MethodUtils.isTrivial(method, false)) {
return;
}
registerMethodError(method, Boolean.FALSE);
}
示例14: visitClassInitializer
import com.siyeh.ig.psiutils.TestUtils; //导入依赖的package包/类
@Override
public void visitClassInitializer(PsiClassInitializer initializer) {
if (initializer.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiClass aClass = initializer.getContainingClass();
if (!TestUtils.isJUnitTestClass(aClass) && !TestUtils.isJUnit4TestClass(aClass, true)) {
return;
}
if (MethodUtils.isTrivial(initializer)) {
return;
}
registerClassInitializerError(initializer, Boolean.TRUE);
}
示例15: 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