Skip to content

Commit 817a4b2

Browse files
author
jossonsmith
committed
Merge with trunk for supporting Test Suites
1 parent 8dc971e commit 817a4b2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/net/sf/j2s/ui/launching/J2SUnitLaunchingUtil.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.HashSet;
1111
import java.util.Properties;
1212
import java.util.Set;
13+
import net.sf.j2s.core.astvisitors.Bindings;
1314
import net.sf.j2s.core.astvisitors.DependencyASTVisitor;
1415
import net.sf.j2s.ui.classpath.CompositeResources;
1516
import net.sf.j2s.ui.classpath.ContactedClasses;
@@ -28,7 +29,10 @@
2829
import org.eclipse.debug.core.ILaunchConfiguration;
2930
import org.eclipse.jdt.core.IJavaModel;
3031
import org.eclipse.jdt.core.IJavaProject;
32+
import org.eclipse.jdt.core.IMethod;
33+
import org.eclipse.jdt.core.IType;
3134
import org.eclipse.jdt.core.JavaCore;
35+
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
3236
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
3337
import org.eclipse.jface.dialogs.MessageDialog;
3438
import org.eclipse.swt.widgets.Display;
@@ -642,7 +646,23 @@ private static String generateHTML(ILaunchConfiguration configuration,
642646
buf.append("ClazzLoader.loadClass (\"junit.textui.TestRunner\", function () {\r\n");
643647
buf.append("ClazzLoader.loadClass (\"" + mainType + "\", function () {\r\n");
644648
//buf.append("" + mainType + ".main(" + ArgsUtil.wrapAsArgumentArray(args) + ");\r\n");
645-
buf.append("junit.textui.TestRunner.run (" + mainType + ");\r\n");
649+
IType mType = JavaModelUtil.findType(javaProject, mainType);
650+
boolean isTestSuite = false;
651+
if (mType != null) {
652+
IMethod suiteMethod = JavaModelUtil.findMethod("suite", new String[0], false, mType);
653+
if (suiteMethod != null) {
654+
String returnType = suiteMethod.getReturnType();
655+
if ("QTest;".equals(returnType)
656+
|| "Qjunit.framework.Test;".equals(returnType) ) {
657+
isTestSuite = true;
658+
}
659+
}
660+
}
661+
if (isTestSuite) {
662+
buf.append("junit.textui.TestRunner.run (" + mainType + ".suite ());\r\n");
663+
} else {
664+
buf.append("junit.textui.TestRunner.run (" + mainType + ");\r\n");
665+
}
646666
buf.append("});\r\n");
647667
buf.append("});\r\n");
648668
buf.append("</script>\r\n");

0 commit comments

Comments
 (0)