|
10 | 10 | import java.util.HashSet; |
11 | 11 | import java.util.Properties; |
12 | 12 | import java.util.Set; |
| 13 | +import net.sf.j2s.core.astvisitors.Bindings; |
13 | 14 | import net.sf.j2s.core.astvisitors.DependencyASTVisitor; |
14 | 15 | import net.sf.j2s.ui.classpath.CompositeResources; |
15 | 16 | import net.sf.j2s.ui.classpath.ContactedClasses; |
|
28 | 29 | import org.eclipse.debug.core.ILaunchConfiguration; |
29 | 30 | import org.eclipse.jdt.core.IJavaModel; |
30 | 31 | import org.eclipse.jdt.core.IJavaProject; |
| 32 | +import org.eclipse.jdt.core.IMethod; |
| 33 | +import org.eclipse.jdt.core.IType; |
31 | 34 | import org.eclipse.jdt.core.JavaCore; |
| 35 | +import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
32 | 36 | import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
33 | 37 | import org.eclipse.jface.dialogs.MessageDialog; |
34 | 38 | import org.eclipse.swt.widgets.Display; |
@@ -642,7 +646,23 @@ private static String generateHTML(ILaunchConfiguration configuration, |
642 | 646 | buf.append("ClazzLoader.loadClass (\"junit.textui.TestRunner\", function () {\r\n"); |
643 | 647 | buf.append("ClazzLoader.loadClass (\"" + mainType + "\", function () {\r\n"); |
644 | 648 | //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 | + } |
646 | 666 | buf.append("});\r\n"); |
647 | 667 | buf.append("});\r\n"); |
648 | 668 | buf.append("</script>\r\n"); |
|
0 commit comments