mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: check constructor calls to support JMockit (IDEA-184438)
This commit is contained in:
@@ -137,7 +137,6 @@ com.siyeh.ig.javabeans.ClassWithoutNoArgConstructorInspection
|
||||
com.siyeh.ig.javadoc.UnnecessaryJavaDocLinkInspection
|
||||
com.siyeh.ig.jdk.AutoBoxingInspection
|
||||
com.siyeh.ig.junit.TestCaseWithNoTestMethodsInspection
|
||||
com.siyeh.ig.junit.TestMethodWithoutAssertionInspection
|
||||
com.siyeh.ig.logging.ClassWithMultipleLoggersInspection
|
||||
com.siyeh.ig.logging.ClassWithoutLoggerInspection
|
||||
com.siyeh.ig.logging.LoggerInitializedWithForeignClassInspection
|
||||
|
||||
+5
-16
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.siyeh.ig.junit;
|
||||
|
||||
@@ -34,7 +22,7 @@ public class TestMethodWithoutAssertionInspectionBase extends BaseInspection {
|
||||
@SuppressWarnings("PublicField") public boolean assertKeywordIsAssertion;
|
||||
|
||||
public TestMethodWithoutAssertionInspectionBase() {
|
||||
methodMatcher = new MethodMatcher(true, "assertionMethods")
|
||||
methodMatcher = new MethodMatcher(false, "assertionMethods")
|
||||
.add(JUnitCommonClassNames.ORG_JUNIT_ASSERT, "assert.*|fail.*")
|
||||
.add(JUnitCommonClassNames.JUNIT_FRAMEWORK_ASSERT, "assert.*|fail.*")
|
||||
.add(JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_ASSERTIONS, "assert.*|fail.*")
|
||||
@@ -45,6 +33,7 @@ public class TestMethodWithoutAssertionInspectionBase extends BaseInspection {
|
||||
.add("org.mockito.InOrder", "verify")
|
||||
.add("org.junit.rules.ExpectedException", "expect.*")
|
||||
.add("org.hamcrest.MatcherAssert", "assertThat")
|
||||
.add("mockit.Verifications", "Verifications")
|
||||
.finishDefault();
|
||||
}
|
||||
|
||||
@@ -150,11 +139,11 @@ public class TestMethodWithoutAssertionInspectionBase extends BaseInspection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
|
||||
public void visitCallExpression(@NotNull PsiCallExpression call) {
|
||||
if (containsAssertion) {
|
||||
return;
|
||||
}
|
||||
super.visitMethodCallExpression(call);
|
||||
super.visitCallExpression(call);
|
||||
if (methodMatcher.matches(call)) {
|
||||
containsAssertion = true;
|
||||
}
|
||||
|
||||
+10
@@ -3,6 +3,7 @@ package com.siyeh.igtest.junit;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
import mockit.*;
|
||||
|
||||
public class TestMethodWithoutAssertion extends TestCase
|
||||
{
|
||||
@@ -57,4 +58,13 @@ public class TestMethodWithoutAssertion extends TestCase
|
||||
private void check() {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteReverseAcknowledgement(@Mocked final Object messageDAO) {
|
||||
System.out.println(messageDAO);
|
||||
|
||||
new Verifications() {{
|
||||
messageDAO.toString();
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
||||
+12
-15
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.siyeh.ig.junit;
|
||||
|
||||
@@ -54,9 +42,18 @@ public class TestMethodWithoutAssertionInspectionTest extends LightInspectionTes
|
||||
"}",
|
||||
|
||||
"package junit.framework;" +
|
||||
"public abstract class TestCase extends Assert {}"
|
||||
};
|
||||
"public abstract class TestCase extends Assert {}",
|
||||
|
||||
"package mockit;" +
|
||||
"public abstract class Verifications {" +
|
||||
" protected Verifications() {}" +
|
||||
"}",
|
||||
|
||||
"package mockit;" +
|
||||
"@java.lang.annotation.Retention(value=RUNTIME)\n" +
|
||||
"@java.lang.annotation.Target(value={FIELD,PARAMETER})" +
|
||||
"public @interface Mocked {}"
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user