mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
[jvm] Migrate quickfix with preview tests to its own method
GitOrigin-RevId: d9d03e28c8344ebdf2592564b4707a2f3b2bbb23
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5051907237
commit
c23e68a190
@@ -134,7 +134,7 @@ class JavaJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase() {
|
||||
}
|
||||
|
||||
fun `test quickfix class expression suite converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
@@ -164,11 +164,11 @@ class JavaJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase() {
|
||||
@Suite.SuiteClasses({Foo.class, Bar.class})
|
||||
class JUnit3Test {
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix nested suite converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
@@ -211,11 +211,11 @@ class JavaJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase() {
|
||||
@Suite.SuiteClasses({Foo.class})
|
||||
class JUnit3Test {
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix assertion converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import junit.framework.TestCase;
|
||||
|
||||
class JUnit3<caret>Test extends TestCase {
|
||||
@@ -234,11 +234,11 @@ class JavaJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase() {
|
||||
Assert.assertEquals(2, 1 + 1);
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix setup and teardown converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import junit.framework.TestCase;
|
||||
|
||||
class JUnit3<caret>Test extends TestCase {
|
||||
@@ -284,6 +284,6 @@ class JavaJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase() {
|
||||
System.out.println("tearDown");
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed parameterized add test instance quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
@@ -447,10 +447,10 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@ParameterizedTest
|
||||
void foo(String param) { }
|
||||
}
|
||||
""".trimIndent(), "Annotate class 'Test' as '@TestInstance'", true)
|
||||
""".trimIndent(), "Annotate class 'Test' as '@TestInstance'")
|
||||
}
|
||||
fun `test malformed parameterized introduce method source quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@@ -475,7 +475,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@ParameterizedTest
|
||||
void foo(String param) { }
|
||||
}
|
||||
""".trimIndent(), "Create method 'parameters' in 'Test'", true)
|
||||
""".trimIndent(), "Create method 'parameters' in 'Test'")
|
||||
}
|
||||
fun `test malformed parameterized create csv source quickfix`() {
|
||||
val file = myFixture.addFileToProject("CsvFile.java", """
|
||||
@@ -592,7 +592,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed before change signature quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class MainTest {
|
||||
@org.junit.Before
|
||||
String bef<caret>ore(int i) { return ""; }
|
||||
@@ -602,10 +602,10 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.Before
|
||||
public void before() { return ""; }
|
||||
}
|
||||
""".trimIndent(), "Fix 'before' method signature", true)
|
||||
""".trimIndent(), "Fix 'before' method signature")
|
||||
}
|
||||
fun `test malformed before remove private quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class MainTest {
|
||||
@org.junit.jupiter.api.BeforeEach
|
||||
private void bef<caret>oreEach() { }
|
||||
@@ -615,7 +615,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.jupiter.api.BeforeEach
|
||||
public void beforeEach() { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'beforeEach' method signature", true)
|
||||
""".trimIndent(), "Fix 'beforeEach' method signature")
|
||||
}
|
||||
fun `test malformed before class no highlighting`() {
|
||||
myFixture.testHighlighting(JvmLanguage.JAVA, """
|
||||
@@ -661,7 +661,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed before all quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class MainTest {
|
||||
@org.junit.jupiter.api.BeforeAll
|
||||
String before<caret>All(int i) { return ""; }
|
||||
@@ -671,7 +671,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.jupiter.api.BeforeAll
|
||||
static void beforeAll() { return ""; }
|
||||
}
|
||||
""".trimIndent(), "Fix 'beforeAll' method signature", true)
|
||||
""".trimIndent(), "Fix 'beforeAll' method signature")
|
||||
}
|
||||
|
||||
/* Malformed Datapoint(s) */
|
||||
@@ -718,7 +718,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed dataPoint quickfix make method public and static`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class Test {
|
||||
@org.junit.experimental.theories.DataPoint Object f<caret>1() { return null; }
|
||||
}
|
||||
@@ -727,7 +727,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.experimental.theories.DataPoint
|
||||
public static Object f1() { return null; }
|
||||
}
|
||||
""".trimIndent(), "Fix 'f1' method signature", true)
|
||||
""".trimIndent(), "Fix 'f1' method signature")
|
||||
}
|
||||
|
||||
/* Malformed setup/teardown */
|
||||
@@ -747,7 +747,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent(), "C")
|
||||
}
|
||||
fun `test malformed setup quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class C extends junit.framework.TestCase {
|
||||
private void set<caret>Up(int i) { }
|
||||
}
|
||||
@@ -755,7 +755,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
class C extends junit.framework.TestCase {
|
||||
public void setUp() { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'setUp' method signature", true)
|
||||
""".trimIndent(), "Fix 'setUp' method signature")
|
||||
}
|
||||
|
||||
/* Malformed rule */
|
||||
@@ -833,7 +833,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed rule make field public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class RuleQfTest {
|
||||
@org.junit.Rule
|
||||
private int x<caret>;
|
||||
@@ -843,10 +843,10 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.Rule
|
||||
public int x;
|
||||
}
|
||||
""".trimIndent(), "Fix 'x' field signature", true)
|
||||
""".trimIndent(), "Fix 'x' field signature")
|
||||
}
|
||||
fun `test malformed rule make field non-static quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class RuleQfTest {
|
||||
@org.junit.Rule
|
||||
public static int y<caret>() { return 0; }
|
||||
@@ -856,10 +856,10 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.Rule
|
||||
public int y() { return 0; }
|
||||
}
|
||||
""".trimIndent(), "Fix 'y' method signature", true)
|
||||
""".trimIndent(), "Fix 'y' method signature")
|
||||
}
|
||||
fun `test malformed class rule make field public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
class SomeTestRule implements org.junit.rules.TestRule {
|
||||
@org.jetbrains.annotations.NotNull
|
||||
@Override
|
||||
@@ -887,7 +887,7 @@ class JavaJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationIns
|
||||
@org.junit.ClassRule
|
||||
public static SomeTestRule x = new SomeTestRule();
|
||||
}
|
||||
""".trimIndent(), "Fix 'x' field signature", true)
|
||||
""".trimIndent(), "Fix 'x' field signature")
|
||||
}
|
||||
fun `test malformed class rule make field static quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
|
||||
@@ -55,7 +55,7 @@ class JavaJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTestB
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove before each annotation quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
@org.junit.jupiter.api.BeforeEach
|
||||
public void do<caret>Something() { }
|
||||
@@ -64,12 +64,12 @@ class JavaJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTestB
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
public void doSomething() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@BeforeEach' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@BeforeEach' annotation")
|
||||
}
|
||||
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove test annotation without rename quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
@org.junit.Test
|
||||
public void test<caret>Foo() { }
|
||||
@@ -78,11 +78,11 @@ class JavaJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTestB
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
public void testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation")
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove test annotation and rename quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
@org.junit.Test
|
||||
public void f<caret>oo() { }
|
||||
@@ -91,11 +91,11 @@ class JavaJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTestB
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
public void testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation")
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove ignore annotation and rename quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.JAVA, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.JAVA, """
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
@org.junit.Ignore
|
||||
public void test<caret>Foo() { }
|
||||
@@ -104,7 +104,7 @@ class JavaJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTestB
|
||||
public class MyTest extends junit.framework.TestCase {
|
||||
public void _testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Ignore' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Ignore' annotation")
|
||||
}
|
||||
|
||||
fun `test highlighting junit 4 test case with junit 5 test`() {
|
||||
|
||||
@@ -150,7 +150,7 @@ class KotlinJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase()
|
||||
}
|
||||
|
||||
fun `test quickfix class expression suite converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import junit.framework.TestCase
|
||||
import junit.framework.TestSuite
|
||||
import junit.framework.Test
|
||||
@@ -185,11 +185,11 @@ class KotlinJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase()
|
||||
companion object {
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix nested suite converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import junit.framework.TestCase
|
||||
import junit.framework.TestSuite
|
||||
import junit.framework.Test
|
||||
@@ -243,11 +243,11 @@ class KotlinJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase()
|
||||
companion object {
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix assertion converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import junit.framework.TestCase
|
||||
|
||||
class JUnit3<caret>Test : TestCase {
|
||||
@@ -266,11 +266,11 @@ class KotlinJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase()
|
||||
Assert.assertEquals(2, 1 + 1)
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
|
||||
fun `test quickfix setup and teardown converter`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import junit.framework.TestCase
|
||||
|
||||
class JUnit3<caret>Test : TestCase {
|
||||
@@ -314,6 +314,6 @@ class KotlinJUnit4ConverterInspectionTest : JUnit4ConverterInspectionTestBase()
|
||||
println("tearDown")
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Convert to JUnit 4 test case", true)
|
||||
""".trimIndent(), "Convert to JUnit 4 test case")
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed extension make public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class A {
|
||||
@org.junit.jupiter.api.extension.RegisterExtension
|
||||
val myRule<caret>5 = Rule5()
|
||||
@@ -54,7 +54,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
val myRule5 = Rule5()
|
||||
class Rule5 { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'myRule5' field signature", true)
|
||||
""".trimIndent(), "Fix 'myRule5' field signature")
|
||||
}
|
||||
|
||||
/* Malformed nested class */
|
||||
@@ -75,7 +75,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed nested class quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class A {
|
||||
@org.junit.jupiter.api.Nested
|
||||
class B<caret> { }
|
||||
@@ -85,7 +85,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@org.junit.jupiter.api.Nested
|
||||
inner class B { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'B' class signature", true)
|
||||
""".trimIndent(), "Fix 'B' class signature")
|
||||
}
|
||||
|
||||
/* Malformed parameterized */
|
||||
@@ -464,7 +464,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed parameterized add test instance quick fix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.MethodSource
|
||||
@@ -494,7 +494,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@ParameterizedTest
|
||||
fun foo(param: String) { }
|
||||
}
|
||||
""".trimIndent(), "Annotate as @TestInstance", true)
|
||||
""".trimIndent(), "Annotate as @TestInstance")
|
||||
}
|
||||
fun `test malformed parameterized introduce method source quick fix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
@@ -524,7 +524,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Add method 'parameters' to 'Test'", false) // TODO make createMethod preview work
|
||||
""".trimIndent(), "Add method 'parameters' to 'Test'") // TODO make createMethod preview work
|
||||
}
|
||||
fun `test malformed parameterized create csv source quick fix`() {
|
||||
val file = myFixture.addFileToProject("CsvFile.kt", """
|
||||
@@ -644,7 +644,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed before each remove private quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class MainTest {
|
||||
@org.junit.jupiter.api.BeforeEach
|
||||
private fun bef<caret>oreEach() { }
|
||||
@@ -656,7 +656,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@BeforeEach
|
||||
fun beforeEach(): Unit { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'beforeEach' method signature", true)
|
||||
""".trimIndent(), "Fix 'beforeEach' method signature")
|
||||
}
|
||||
fun `test malformed before class no highlighting`() {
|
||||
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
|
||||
@@ -816,7 +816,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed before all quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
|
||||
class MainTest {
|
||||
@@ -835,7 +835,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Fix 'beforeAll' method signature", true)
|
||||
""".trimIndent(), "Fix 'beforeAll' method signature")
|
||||
}
|
||||
|
||||
/* Malformed datapoint(s) */
|
||||
@@ -895,7 +895,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed datapoint make field public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class Test {
|
||||
companion object {
|
||||
@org.junit.experimental.theories.DataPoint
|
||||
@@ -910,10 +910,10 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
val f1: Any? = null
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Fix 'f1' field signature", true)
|
||||
""".trimIndent(), "Fix 'f1' field signature")
|
||||
}
|
||||
fun `test malformed datapoint make field public and static quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class Test {
|
||||
@org.junit.experimental.theories.DataPoint
|
||||
val f<caret>1: Any? = null
|
||||
@@ -926,10 +926,10 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
val f1: Any? = null
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Fix 'f1' field signature", true)
|
||||
""".trimIndent(), "Fix 'f1' field signature")
|
||||
}
|
||||
fun `test malformed datapoint make method public and static quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class Test {
|
||||
@org.junit.experimental.theories.DataPoint
|
||||
private fun f<caret>1(): Any? = null
|
||||
@@ -942,7 +942,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
fun f1(): Any? = null
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Fix 'f1' method signature", true)
|
||||
""".trimIndent(), "Fix 'f1' method signature")
|
||||
}
|
||||
|
||||
/* Malformed setup/teardown */
|
||||
@@ -961,7 +961,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed setup quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class C : junit.framework.TestCase() {
|
||||
private fun set<caret>Up(i: Int) { }
|
||||
}
|
||||
@@ -969,7 +969,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
class C : junit.framework.TestCase() {
|
||||
fun setUp(): Unit { }
|
||||
}
|
||||
""".trimIndent(), "Fix 'setUp' method signature", true)
|
||||
""".trimIndent(), "Fix 'setUp' method signature")
|
||||
}
|
||||
|
||||
|
||||
@@ -1054,7 +1054,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed rule make field public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class PrivateRule {
|
||||
@org.junit.Rule
|
||||
var x<caret> = 0
|
||||
@@ -1065,10 +1065,10 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@org.junit.Rule
|
||||
var x = 0
|
||||
}
|
||||
""".trimIndent(), "Fix 'x' field signature", true)
|
||||
""".trimIndent(), "Fix 'x' field signature")
|
||||
}
|
||||
fun `test malformed class rule make field public quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class SomeTestRule : org.junit.rules.TestRule {
|
||||
override fun apply(base: org.junit.runners.model.Statement, description: org.junit.runner.Description): org.junit.runners.model.Statement = base
|
||||
}
|
||||
@@ -1087,7 +1087,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@org.junit.ClassRule
|
||||
var x = SomeTestRule()
|
||||
}
|
||||
""".trimIndent(), "Fix 'x' field signature", true)
|
||||
""".trimIndent(), "Fix 'x' field signature")
|
||||
}
|
||||
|
||||
/* Malformed test */
|
||||
@@ -1153,7 +1153,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed suite quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
class Junit3Suite : junit.framework.TestCase() {
|
||||
fun sui<caret>te() = junit.framework.TestSuite()
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
fun suite() = junit.framework.TestSuite()
|
||||
}
|
||||
}
|
||||
""".trimIndent(), "Fix 'suite' method signature", true)
|
||||
""".trimIndent(), "Fix 'suite' method signature")
|
||||
}
|
||||
|
||||
/* Suspending test function */
|
||||
|
||||
@@ -55,7 +55,7 @@ class KotlinJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTes
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove annotation quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
@org.junit.Test
|
||||
public fun test<caret>Foo() { }
|
||||
@@ -64,11 +64,11 @@ class KotlinJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTes
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
public fun testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation")
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove test annotation and rename quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
@org.junit.Test
|
||||
public fun f<caret>oo() { }
|
||||
@@ -77,11 +77,11 @@ class KotlinJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTes
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
public fun testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Test' annotation")
|
||||
}
|
||||
|
||||
fun `test junit 3 test case with junit 4 test remove ignore annotation and rename quickfix`() {
|
||||
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
|
||||
myFixture.testQuickFixWithPreview(JvmLanguage.KOTLIN, """
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
@org.junit.Ignore
|
||||
public fun testF<caret>oo() { }
|
||||
@@ -90,7 +90,7 @@ class KotlinJUnitMixedFrameworkInspectionTest : JUnitMixedFrameworkInspectionTes
|
||||
public class MyTest : junit.framework.TestCase() {
|
||||
public fun _testFoo() { }
|
||||
}
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Ignore' annotation", testPreview = true)
|
||||
""".trimIndent(), fileName = "MyTest", hint = "Remove '@Ignore' annotation")
|
||||
}
|
||||
|
||||
fun `test highlighting junit 4 test case with junit 5 test`() {
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class JvmInspectionTestBase : LightJavaCodeInsightFixtureTestCase() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the [hint] quickfix on [before] at the cursor position marked with <caret> and compares it with [after].
|
||||
* Run the [hint] quickfix on [before] at the cursor position marked with <caret> and compares the result with [after].
|
||||
*/
|
||||
protected fun JavaCodeInsightTestFixture.testQuickFix(
|
||||
lang: JvmLanguage,
|
||||
@@ -74,11 +74,27 @@ abstract class JvmInspectionTestBase : LightJavaCodeInsightFixtureTestCase() {
|
||||
hint: String = InspectionsBundle.message(
|
||||
"fix.all.inspection.problems.in.file", InspectionTestUtil.instantiateTool(inspection.javaClass).displayName
|
||||
),
|
||||
testPreview: Boolean = false,
|
||||
fileName: String = generateFileName(),
|
||||
) {
|
||||
configureByText("$fileName${lang.ext}", before)
|
||||
if (testPreview) testPreview(lang, before, after, hint, fileName)
|
||||
runQuickFix(hint)
|
||||
checkResult(after)
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the [hint] quickfix on [before] at the cursor position marked with <caret> and compares the result and the preview with [after].
|
||||
*/
|
||||
protected fun JavaCodeInsightTestFixture.testQuickFixWithPreview(
|
||||
lang: JvmLanguage,
|
||||
before: String,
|
||||
after: String,
|
||||
hint: String = InspectionsBundle.message(
|
||||
"fix.all.inspection.problems.in.file", InspectionTestUtil.instantiateTool(inspection.javaClass).displayName
|
||||
),
|
||||
fileName: String = generateFileName(),
|
||||
) {
|
||||
configureByText("$fileName${lang.ext}", before)
|
||||
testPreview(lang, before, after, hint, fileName)
|
||||
runQuickFix(hint)
|
||||
checkResult(after)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user