diff --git a/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritor.java b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritor.java new file mode 100644 index 000000000000..7ee82ad317c1 --- /dev/null +++ b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritor.java @@ -0,0 +1,4 @@ +package test1; +public class TestCaseInheritor extends junit.framework.TestCase { + public void test1() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorMultipleConstructor.java b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorMultipleConstructor.java new file mode 100644 index 000000000000..11312a5f21cc --- /dev/null +++ b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorMultipleConstructor.java @@ -0,0 +1,5 @@ +package test1; +public class TestCaseInheritorMultipleConstructor extends junit.framework.TestCase { + public TestCaseInheritorMultipleConstructor(String s) {} + public void test1() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorNoConstructor.java b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorNoConstructor.java new file mode 100644 index 000000000000..79c5dd689839 --- /dev/null +++ b/java/java-tests/testData/junit/configurations/module6/test1/TestCaseInheritorNoConstructor.java @@ -0,0 +1,5 @@ +package test1; +public class TestCaseInheritorNoConstructor extends junit.framework.TestCase { + private TestCaseInheritorNoConstructor() {} + public void test1() {} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java b/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java index bbe4a0c8dc2f..7848939f6877 100644 --- a/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java +++ b/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java @@ -34,6 +34,8 @@ import com.intellij.execution.testframework.SearchForTestsTask; import com.intellij.execution.testframework.TestSearchScope; import com.intellij.execution.ui.CommonJavaParametersPanel; import com.intellij.openapi.Disposable; +import com.intellij.openapi.compiler.CompilerMessage; +import com.intellij.openapi.compiler.CompilerMessageCategory; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.options.Configurable; @@ -226,6 +228,19 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { CHECK.containsAll(tests, new Object[]{ancestorTest, childTest1, childTest2}); } + public void testConstructors() throws IOException, ExecutionException { + addModule("module6", true); + PsiPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage("test1"); + JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext()); + configuration.getPersistentData().setScope(TestSearchScope.SINGLE_MODULE); + configuration.setModule(getModule(3)); + assertNotNull(configuration); + checkPackage(psiPackage.getQualifiedName(), configuration); + JavaParameters parameters = checkCanRun(configuration); + List tests = extractAllInPackageTests(parameters, psiPackage); + CHECK.containsAll(tests, new Object[]{"test1.TestCaseInheritor"}); + } + public void testClasspathConfiguration() throws CantRunException { JavaParameters parameters = new JavaParameters(); RunConfigurationModule module = new JavaRunConfigurationModule(myProject, false); @@ -482,7 +497,8 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { try { CompilerTester tester = new CompilerTester(project, Arrays.asList(ModuleManager.getInstance(project).getModules())); try { - tester.make(); + List messages = tester.make(); + assertFalse(messages.stream().anyMatch(message -> message.getCategory() == CompilerMessageCategory.ERROR)); task.startSearch(); } finally { diff --git a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java index d0219562dd2e..4afd070ad9d9 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java @@ -274,7 +274,6 @@ public class TestPackage extends TestObject { private static boolean hasSingleConstructor(Class aClass) { Constructor[] constructors = aClass.getConstructors(); - return constructors.length == 0 || - constructors.length == 1 && constructors[0].getParameterTypes().length == 0; + return constructors.length == 1 && constructors[0].getParameterTypes().length == 0; } }