|
Lines 31-36
Link Here
|
| 31 |
import org.eclipse.swt.widgets.Display; |
31 |
import org.eclipse.swt.widgets.Display; |
| 32 |
|
32 |
|
| 33 |
import org.eclipse.jdt.core.ICompilationUnit; |
33 |
import org.eclipse.jdt.core.ICompilationUnit; |
|
|
34 |
import org.eclipse.jdt.core.IJavaElement; |
| 35 |
import org.eclipse.jdt.core.IMethod; |
| 34 |
import org.eclipse.jdt.core.IPackageFragment; |
36 |
import org.eclipse.jdt.core.IPackageFragment; |
| 35 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
37 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
| 36 |
import org.eclipse.jdt.core.IType; |
38 |
import org.eclipse.jdt.core.IType; |
|
Lines 57-63
Link Here
|
| 57 |
String fSerialized; |
59 |
String fSerialized; |
| 58 |
} |
60 |
} |
| 59 |
|
61 |
|
| 60 |
private SerializationResult launchTest(IType typeToLaunch) throws Exception { |
62 |
private SerializationResult launchTest(IJavaElement elementToLaunch) throws Exception { |
| 61 |
final SerializationResult result= new SerializationResult(); |
63 |
final SerializationResult result= new SerializationResult(); |
| 62 |
|
64 |
|
| 63 |
TestRunListener testRunListener= new TestRunListener() { |
65 |
TestRunListener testRunListener= new TestRunListener() { |
|
Lines 69-75
Link Here
|
| 69 |
|
71 |
|
| 70 |
JUnitCore.addTestRunListener(testRunListener); |
72 |
JUnitCore.addTestRunListener(testRunListener); |
| 71 |
try { |
73 |
try { |
| 72 |
new AbstractTestRunListenerTest().launchJUnit(typeToLaunch); |
74 |
new AbstractTestRunListenerTest().launchJUnit(elementToLaunch); |
| 73 |
assertTrue(new DisplayHelper(){ |
75 |
assertTrue(new DisplayHelper(){ |
| 74 |
protected boolean condition() { |
76 |
protected boolean condition() { |
| 75 |
return result.fTestRunSession != null; |
77 |
return result.fTestRunSession != null; |
|
Lines 86-92
Link Here
|
| 86 |
return result; |
88 |
return result; |
| 87 |
} |
89 |
} |
| 88 |
|
90 |
|
| 89 |
private void runExportImport(IType test, String expectedXML) throws Exception { |
91 |
private void runExportImport(IJavaElement test, String expectedXML) throws Exception { |
| 90 |
SerializationResult serializationResult= launchTest(test); |
92 |
SerializationResult serializationResult= launchTest(test); |
| 91 |
assertEqualXML(expectedXML, serializationResult.fSerialized); |
93 |
assertEqualXML(expectedXML, serializationResult.fSerialized); |
| 92 |
|
94 |
|
|
Lines 222-225
Link Here
|
| 222 |
JUnitModel.importTestRunSession(testFile); // no contents check for now... |
224 |
JUnitModel.importTestRunSession(testFile); // no contents check for now... |
| 223 |
} |
225 |
} |
| 224 |
|
226 |
|
|
|
227 |
protected void runMethodTest(String testType, String method) throws Exception { |
| 228 |
IPackageFragmentRoot root= JUnitWorkspaceTestSetup.getRoot(); |
| 229 |
IPackageFragment pack= root.getPackageFragment("pack"); |
| 230 |
ICompilationUnit cu= pack.getCompilationUnit(testType + ".java"); |
| 231 |
IType testCase= cu.findPrimaryType(); |
| 232 |
IMethod testMethod= testCase.getMethod(method, new String[0]); |
| 233 |
|
| 234 |
Path expectedPath= new Path(JUnitWorkspaceTestSetup.getProjectPath() + "xml/" + testType + "_" + method + ".xml"); |
| 235 |
File expectedFile= JavaTestPlugin.getDefault().getFileInPlugin(expectedPath); |
| 236 |
String expected= getContents(new FileInputStream(expectedFile)); |
| 237 |
runExportImport(testMethod, expected); |
| 238 |
|
| 239 |
//ant cannot run single test methods |
| 240 |
} |
| 241 |
|
| 225 |
} |
242 |
} |