From afb1cf80d04e45efbf30a38fd754fb6dec0926eb Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 8 Dec 2015 20:46:35 +0100 Subject: [PATCH] IG: add test --- ...implifiableJUnit40AssertionInspection.java | 15 ---- .../SimplifiableJUnit40Assertion.java | 15 ++++ .../SimplifiableJUnitAssertion.java} | 12 +-- ...plifiableJUnitAssertionInspectionTest.java | 78 +++++++++++++++++++ 4 files changed, 99 insertions(+), 21 deletions(-) delete mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnit40AssertionInspection.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnit40Assertion.java rename plugins/InspectionGadgets/test/com/siyeh/igtest/junit/{SimplifiableJUnitAssertionInspection.java => simplifiable_junit_assertion/SimplifiableJUnitAssertion.java} (59%) create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/SimplifiableJUnitAssertionInspectionTest.java diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnit40AssertionInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnit40AssertionInspection.java deleted file mode 100644 index bced06e0bccb..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnit40AssertionInspection.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.siyeh.igtest.junit; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class SimplifiableJUnit40AssertionInspection { - @Test - public void test() - { - assertTrue(3 == 4); - assertEquals(false, new Object() != null); - assertTrue(false); - assertFalse("foo", true); - } -} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnit40Assertion.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnit40Assertion.java new file mode 100644 index 000000000000..2523ef166a07 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnit40Assertion.java @@ -0,0 +1,15 @@ +package com.siyeh.igtest.junit; + +import static org.junit.Assert.*; +import org.junit.Test; + +public class SimplifiableJUnit40Assertion { + @Test + public void test() + { + assertTrue(3 == 4); + assertEquals(false, new Object() != null); + assertTrue(false); + assertFalse("foo", true); + } +} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnitAssertionInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnitAssertion.java similarity index 59% rename from plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnitAssertionInspection.java rename to plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnitAssertion.java index 00fe18f83ea7..f554833cefee 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/SimplifiableJUnitAssertionInspection.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/simplifiable_junit_assertion/SimplifiableJUnitAssertion.java @@ -4,15 +4,15 @@ import junit.framework.TestCase; import java.util.Collection; -public class SimplifiableJUnitAssertionInspection extends TestCase{ +public class SimplifiableJUnitAssertion extends TestCase{ public void test() { - assertTrue(3 == 4); - assertEquals(false, new Object() != null); - assertTrue(false); - assertFalse("foo", true); + assertTrue(3 == 4); + assertEquals(false, new Object() != null); + assertTrue(false); + assertFalse("foo", true); Collection collection = null; - assertTrue(collection.size() == 2); + assertTrue(collection.size() == 2); } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/SimplifiableJUnitAssertionInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/SimplifiableJUnitAssertionInspectionTest.java new file mode 100644 index 000000000000..ca4b6ce7ff5d --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/SimplifiableJUnitAssertionInspectionTest.java @@ -0,0 +1,78 @@ +/* + * 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. + */ +package com.siyeh.ig.junit; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import junit.framework.TestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class SimplifiableJUnitAssertionInspectionTest extends LightInspectionTestCase { + + public void testSimplifiableJUnitAssertion() { + doTest(); + } + + public void testSimplifiableJUnit40Assertion() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new SimplifiableJUnitAssertionInspection(); + } + + @Override + protected String[] getEnvironmentClasses() { + return new String[] { + "package junit.framework;" + + "public abstract class TestCase extends Assert {" + + " protected void setUp() throws Exception {}" + + " protected void tearDown() throws Exception {}" + + "}", + + "package junit.framework;" + + "public class Assert {" + + " public static void assertTrue(String message, boolean condition) {}" + + " public static void assertTrue(boolean condition) {}" + + " public static void assertEquals(String message, Object expected, Object actual) {}" + + " public static void assertEquals(Object expected, Object actual) {}" + + " public static void assertFalse(String message, boolean condition) {}" + + " public static void assertFalse(boolean condition) {}" + + "}", + + "package org.junit;" + + "public class Assert {" + + " public static public void assertTrue(boolean condition) {}" + + " public static void assertEquals(boolean expected, boolean actual) {}" + + " public static void assertFalse(String message, boolean condition) {}" + + "}", + + "package org.junit;" + + "import java.lang.annotation.ElementType;" + + "import java.lang.annotation.Retention;" + + "import java.lang.annotation.RetentionPolicy;" + + "import java.lang.annotation.Target;" + + "@Retention(RetentionPolicy.RUNTIME)" + + "@Target({ElementType.METHOD})" + + "public @interface Test {}" + }; + } +} \ No newline at end of file