Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 195624
Collapse All | Expand All

(-)src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java (-2 / +3 lines)
Lines 83-88 Link Here
83
			} else {
83
			} else {
84
				fTestRunSession.reset(); 
84
				fTestRunSession.reset(); 
85
			}
85
			}
86
			fTestSuite= fTestRunSession.getTestRoot();
86
			
87
			
87
		} else if (qName.equals(IXMLTags.NODE_TESTSUITES)) { 
88
		} else if (qName.equals(IXMLTags.NODE_TESTSUITES)) { 
88
			// support Ant's 'junitreport' task; create suite from NODE_TESTSUITE
89
			// support Ant's 'junitreport' task; create suite from NODE_TESTSUITE
Lines 93-104 Link Here
93
			if (fTestRunSession == null) {
94
			if (fTestRunSession == null) {
94
				// support standalone suites and Ant's 'junitreport' task:
95
				// support standalone suites and Ant's 'junitreport' task:
95
				fTestRunSession= new TestRunSession(name, null);
96
				fTestRunSession= new TestRunSession(name, null);
97
				fTestSuite= fTestRunSession.getTestRoot();
96
			}
98
			}
97
			
99
			
98
			String pack= attributes.getValue(IXMLTags.ATTR_PACKAGE);
100
			String pack= attributes.getValue(IXMLTags.ATTR_PACKAGE);
99
			String suiteName= pack == null ? name : pack + "." + name; //$NON-NLS-1$
101
			String suiteName= pack == null ? name : pack + "." + name; //$NON-NLS-1$
100
			TestSuiteElement parent= fTestSuite == null ? fTestRunSession.getTestRoot() : fTestSuite;
102
			fTestSuite= (TestSuiteElement) fTestRunSession.createTestElement(fTestSuite, getNextId(), suiteName, true, 0);
101
			fTestSuite= (TestSuiteElement) fTestRunSession.createTestElement(parent, getNextId(), suiteName, true, 0);
102
			fNotRun.push(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_INCOMPLETE)));
103
			fNotRun.push(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_INCOMPLETE)));
103
			
104
			
104
		} else if (qName.equals(IXMLTags.NODE_PROPERTIES) || qName.equals(IXMLTags.NODE_PROPERTY)) {
105
		} else if (qName.equals(IXMLTags.NODE_PROPERTIES) || qName.equals(IXMLTags.NODE_PROPERTY)) {
(-)ui/org/eclipse/jdt/junit/tests/AbstractTestRunSessionSerializationTests.java (-3 / +20 lines)
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
}
(-)ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests3.java (+6 lines)
Lines 37-42 Link Here
37
		runCUTest(test);
37
		runCUTest(test);
38
	}
38
	}
39
	
39
	
40
	public void testATestCase_testSucceed() throws Exception {
41
		String testType= "ATestCase";
42
		String method= "testSucceed";
43
		runMethodTest(testType, method);
44
	}
45
40
	public void testATestSuite() throws Exception {
46
	public void testATestSuite() throws Exception {
41
		String test= "ATestSuite";
47
		String test= "ATestSuite";
42
		runCUTest(test);
48
		runCUTest(test);
(-)ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java (-4 / +4 lines)
Lines 112-118 Link Here
112
		return aTestCase;
112
		return aTestCase;
113
	}
113
	}
114
114
115
	protected void launchJUnit(IType aTestCase) throws CoreException {
115
	protected void launchJUnit(IJavaElement aTest) throws CoreException {
116
		ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
116
		ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
117
		
117
		
118
		ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
118
		ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
Lines 157-163 Link Here
157
		};
157
		};
158
		lm.addLaunchListener(launchesListener);
158
		lm.addLaunchListener(launchesListener);
159
		
159
		
160
		ILaunchConfiguration configuration= TestJUnitLaunchShortcut.createConfiguration(aTestCase);
160
		ILaunchConfiguration configuration= TestJUnitLaunchShortcut.createConfiguration(aTest);
161
		try {
161
		try {
162
			configuration.launch(ILaunchManager.RUN_MODE, null);
162
			configuration.launch(ILaunchManager.RUN_MODE, null);
163
			new DisplayHelper() {
163
			new DisplayHelper() {
Lines 174-181 Link Here
174
			fail("Launch has not terminated");
174
			fail("Launch has not terminated");
175
	}
175
	}
176
	
176
	
177
	protected String[] launchJUnit(IType aTestCase, final TestRunLog log) throws CoreException {
177
	protected String[] launchJUnit(IJavaElement aTest, final TestRunLog log) throws CoreException {
178
		launchJUnit(aTestCase);
178
		launchJUnit(aTest);
179
		
179
		
180
		new DisplayHelper(){
180
		new DisplayHelper(){
181
			protected boolean condition() {
181
			protected boolean condition() {
(-)testresources/JUnitWorkspace/JUnitTests/xml/ATestCase_testSucceed.xml (+4 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<testrun name="ATestCase.testSucceed" project="JUnitTests" tests="1" started="1" failures="0" errors="0" ignored="0">
3
<testcase name="testSucceed" classname="pack.ATestCase"/>
4
</testrun>

Return to bug 195624