diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java index e6baf6ba00a5..ca048e0c41dc 100644 --- a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java +++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java @@ -43,6 +43,7 @@ public class JUnitUtil { @NonNls private static final String TESTSUITE_CLASS = "junit.framework.TestSuite"; @NonNls public static final String TEST_ANNOTATION = "org.junit.Test"; @NonNls public static final String TEST5_ANNOTATION = "org.junit.jupiter.api.Test"; + @NonNls public static final String TEST5_FACTORY_ANNOTATION = "org.junit.jupiter.api.TestFactory"; @NonNls public static final String IGNORE_ANNOTATION = "org.junit.Ignore"; @NonNls public static final String RUN_WITH = "org.junit.runner.RunWith"; @NonNls public static final String DATA_POINT = "org.junit.experimental.theories.DataPoint"; @@ -62,7 +63,9 @@ public class JUnitUtil { public static final String BEFORE_ALL_ANNOTATION_NAME = "org.junit.jupiter.api.BeforeAll"; public static final String AFTER_ALL_ANNOTATION_NAME = "org.junit.jupiter.api.AfterAll"; - private static final Collection TEST_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(TEST_ANNOTATION, TEST5_ANNOTATION)); + private static final Collection TEST_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(TEST_ANNOTATION, + TEST5_ANNOTATION, + TEST5_FACTORY_ANNOTATION)); private static final List INSTANCE_CONFIGS = Arrays.asList(BEFORE_ANNOTATION_NAME, AFTER_ANNOTATION_NAME); private static final List INSTANCE_5_CONFIGS = Arrays.asList(BEFORE_EACH_ANNOTATION_NAME, AFTER_EACH_ANNOTATION_NAME); diff --git a/plugins/junit5_rt_tests/junit5_rt_tests.iml b/plugins/junit5_rt_tests/junit5_rt_tests.iml index ef9de995f5de..3cf7905d1b3e 100644 --- a/plugins/junit5_rt_tests/junit5_rt_tests.iml +++ b/plugins/junit5_rt_tests/junit5_rt_tests.iml @@ -19,5 +19,7 @@ + + \ No newline at end of file diff --git a/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnit5AcceptanceTest.java b/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnit5AcceptanceTest.java new file mode 100644 index 000000000000..b7204c546811 --- /dev/null +++ b/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnit5AcceptanceTest.java @@ -0,0 +1,60 @@ +/* + * 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. + */ +package com.intellij.junit5; + +import com.intellij.execution.junit.JUnitUtil; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiMethod; +import com.intellij.testFramework.EdtTestUtil; +import com.intellij.testFramework.TestRunnerUtil; +import com.intellij.testFramework.fixtures.*; +import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class JUnit5AcceptanceTest { + + private JavaCodeInsightTestFixture myFixture; + + @BeforeEach + void setUp() throws Exception { + IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory(); + TestFixtureBuilder fixtureBuilder = factory.createLightFixtureBuilder(new DefaultLightProjectDescriptor()); + final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture(); + myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true)); + myFixture.setUp(); + } + + @AfterEach + void tearDown() throws Exception { + myFixture.tearDown(); + } + + @Test + void testFactoryMethods() { + TestRunnerUtil.replaceIdeEventQueueSafely(); + EdtTestUtil.runInEdtAndWait(() -> { + PsiClass aClass = myFixture.addClass("class MyTest {@org.junit.jupiter.api.TestFactory java.util.List tests() {return null;}}"); + PsiMethod factoryMethod = aClass.getMethods()[0]; + assertNotNull(factoryMethod); + assertTrue(JUnitUtil.isTestAnnotated(factoryMethod)); + }); + } +}