mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit detection: test for constructor args
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package test1;
|
||||
public class TestCaseInheritor extends junit.framework.TestCase {
|
||||
public void test1() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test1;
|
||||
public class TestCaseInheritorMultipleConstructor extends junit.framework.TestCase {
|
||||
public TestCaseInheritorMultipleConstructor(String s) {}
|
||||
public void test1() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test1;
|
||||
public class TestCaseInheritorNoConstructor extends junit.framework.TestCase {
|
||||
private TestCaseInheritorNoConstructor() {}
|
||||
public void test1() {}
|
||||
}
|
||||
@@ -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<String> 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<CompilerMessage> messages = tester.make();
|
||||
assertFalse(messages.stream().anyMatch(message -> message.getCategory() == CompilerMessageCategory.ERROR));
|
||||
task.startSearch();
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user