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 129929 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/internal/junit/ui/TestViewer.java (-25 / +24 lines)
Lines 12-21 Link Here
12
package org.eclipse.jdt.internal.junit.ui;
12
package org.eclipse.jdt.internal.junit.ui;
13
13
14
import java.util.AbstractList;
14
import java.util.AbstractList;
15
import java.util.ArrayList;
16
import java.util.Arrays;
15
import java.util.Arrays;
17
import java.util.HashSet;
16
import java.util.HashSet;
18
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.LinkedHashSet;
19
import java.util.LinkedList;
19
import java.util.LinkedList;
20
import java.util.List;
20
import java.util.List;
21
import java.util.ListIterator;
21
import java.util.ListIterator;
Lines 461-494 Link Here
461
461
462
	private void updateElementInTree(final TestElement testElement) {
462
	private void updateElementInTree(final TestElement testElement) {
463
		if (isShown(testElement)) {
463
		if (isShown(testElement)) {
464
			ArrayList toCreate= null;
464
			updateShownElementInTree(testElement);
465
			TestElement current= testElement;
466
			while (! (current instanceof TestRoot)) {
467
				if (fTreeViewer.testFindItem(current) == null) {
468
					if (toCreate == null)
469
						toCreate= new ArrayList();
470
					toCreate.add(current);
471
				} else {
472
					TestElement parent= current;
473
					if (toCreate != null) {
474
						ListIterator iter= toCreate.listIterator(toCreate.size()); // backwards, top first
475
						while (iter.hasPrevious()) {
476
							TestElement child= (TestElement) iter.previous();
477
							fTreeViewer.add(parent, child);
478
							parent= child;
479
						}
480
					}					
481
					fTreeViewer.update(current, null);
482
				}
483
				current= (TestElement) fTreeContentProvider.getParent(current);
484
			}
485
			
486
		} else {
465
		} else {
487
			TestElement current= testElement;
466
			TestElement current= testElement;
488
			do {
467
			do {
489
				fTreeViewer.remove(current);
468
				if (fTreeViewer.testFindItem(current) != null)
469
					fTreeViewer.remove(current);
490
				current= current.getParent();
470
				current= current.getParent();
491
			} while (! (current instanceof TestRoot) && ! isShown(current));
471
			} while (! (current instanceof TestRoot) && ! isShown(current));
472
			
473
			while (current != null && ! (current instanceof TestRoot)) {
474
				fTreeViewer.update(current, null);
475
				current= current.getParent();
476
			}
477
		}
478
	}
479
480
	private void updateShownElementInTree(TestElement testElement) {
481
		if (testElement == null || testElement instanceof TestRoot) // paranoia null check
482
			return;
483
		
484
		TestSuiteElement parent= testElement.getParent();
485
		updateShownElementInTree(parent); // make sure parent is shown and up-to-date
486
		
487
		if (fTreeViewer.testFindItem(testElement) == null) {
488
			fTreeViewer.add(parent, testElement); // if not yet in tree: add
489
		} else {
490
			fTreeViewer.update(testElement, null); // if in tree: update
492
		}
491
		}
493
	}
492
	}
494
493
Lines 640-646 Link Here
640
	}
639
	}
641
640
642
	private void clearUpdateAndExpansion() {
641
	private void clearUpdateAndExpansion() {
643
		fNeedUpdate= new HashSet();
642
		fNeedUpdate= new LinkedHashSet();
644
		fAutoClose= new LinkedList();
643
		fAutoClose= new LinkedList();
645
		fAutoExpand= new HashSet();
644
		fAutoExpand= new HashSet();
646
	}
645
	}
(-)src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java (-4 / +4 lines)
Lines 73-84 Link Here
73
			Status status=testCaseElement.getStatus();
73
			Status status=testCaseElement.getStatus();
74
			if (status.isNotRun())
74
			if (status.isNotRun())
75
				return fTestRunnerPart.fTestIcon;
75
				return fTestRunnerPart.fTestIcon;
76
			else if (status.isRunning())
77
				return fTestRunnerPart.fTestRunningIcon;
76
			else if (status.isError())
78
			else if (status.isError())
77
				return fTestRunnerPart.fTestErrorIcon;
79
				return fTestRunnerPart.fTestErrorIcon;
78
			else if (status.isFailure())
80
			else if (status.isFailure())
79
				return fTestRunnerPart.fTestFailIcon;
81
				return fTestRunnerPart.fTestFailIcon;
80
			else if (status.isRunning())
81
				return fTestRunnerPart.fTestRunningIcon;
82
			else if (status.isOK())
82
			else if (status.isOK())
83
				return fTestRunnerPart.fTestOkIcon;
83
				return fTestRunnerPart.fTestOkIcon;
84
			else
84
			else
Lines 88-99 Link Here
88
			Status status= ((TestSuiteElement) element).getStatus();
88
			Status status= ((TestSuiteElement) element).getStatus();
89
			if (status.isNotRun())
89
			if (status.isNotRun())
90
				return fTestRunnerPart.fSuiteIcon;
90
				return fTestRunnerPart.fSuiteIcon;
91
			else if (status.isRunning())
92
				return fTestRunnerPart.fSuiteRunningIcon;
91
			else if (status.isError())
93
			else if (status.isError())
92
				return fTestRunnerPart.fSuiteErrorIcon;
94
				return fTestRunnerPart.fSuiteErrorIcon;
93
			else if (status.isFailure())
95
			else if (status.isFailure())
94
				return fTestRunnerPart.fSuiteFailIcon;
96
				return fTestRunnerPart.fSuiteFailIcon;
95
			else if (status.isRunning())
96
				return fTestRunnerPart.fSuiteRunningIcon;
97
			else if (status.isOK())
97
			else if (status.isOK())
98
				return fTestRunnerPart.fSuiteOkIcon;
98
				return fTestRunnerPart.fSuiteOkIcon;
99
			else
99
			else
(-)src/org/eclipse/jdt/internal/junit/model/TestSuiteElement.java (-6 / +57 lines)
Lines 18-23 Link Here
18
public class TestSuiteElement extends TestElement {
18
public class TestSuiteElement extends TestElement {
19
	
19
	
20
	private List/*<TestElement>*/ fChildren;
20
	private List/*<TestElement>*/ fChildren;
21
	private Status fChildrenStatus;
21
	
22
	
22
	public TestSuiteElement(TestSuiteElement parent, String id, String testName, int childrenCount) {
23
	public TestSuiteElement(TestSuiteElement parent, String id, String testName, int childrenCount) {
23
		super(parent, id, testName);
24
		super(parent, id, testName);
Lines 33-46 Link Here
33
	}
34
	}
34
	
35
	
35
	public Status getStatus() {
36
	public Status getStatus() {
36
		//TODO: Cache failure count in hierarchy? Recheck behavior when introducing filters
37
		Status suiteStatus= getSuiteStatus();
37
		Status suiteStatus= getSuiteStatus();
38
//		Assert.isTrue(suiteStatus.isNotRun()
38
		if (fChildrenStatus != null) {
39
//				|| (suiteStatus == Status.FAILURE || suiteStatus == Status.ERROR));
39
			// must combine children and suite status here, since failures can occur e.g. in @AfterClass
40
		
40
			return Status.combineStatus(fChildrenStatus, suiteStatus);
41
		} else {
42
			return suiteStatus;
43
		}
44
	}
45
	
46
	private Status getCumulatedStatus() {
41
		TestElement[] children= (TestElement[]) fChildren.toArray(new TestElement[fChildren.size()]); // copy list to avoid concurreny problems
47
		TestElement[] children= (TestElement[]) fChildren.toArray(new TestElement[fChildren.size()]); // copy list to avoid concurreny problems
42
		if (children.length == 0)
48
		if (children.length == 0)
43
			return suiteStatus;
49
			return getSuiteStatus();
44
		
50
		
45
		Status cumulated= children[0].getStatus();
51
		Status cumulated= children[0].getStatus();
46
		
52
		
Lines 51-57 Link Here
51
		// not necessary, see special code in Status.combineProgress()
57
		// not necessary, see special code in Status.combineProgress()
52
//		if (suiteStatus.isErrorOrFailure() && cumulated.isNotRun())
58
//		if (suiteStatus.isErrorOrFailure() && cumulated.isNotRun())
53
//			return suiteStatus; //progress is Done if error in Suite and no children run
59
//			return suiteStatus; //progress is Done if error in Suite and no children run
54
		return Status.combineStatus(cumulated, suiteStatus);
60
		return cumulated;
55
	}
61
	}
56
62
57
	public Status getSuiteStatus() {
63
	public Status getSuiteStatus() {
Lines 62-65 Link Here
62
		return super.toString() + " (" + fChildren.size() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
68
		return super.toString() + " (" + fChildren.size() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
63
	}
69
	}
64
70
71
	public void childChangedStatus(TestElement child, Status childStatus) {
72
		int childCount= fChildren.size();
73
		if (child == fChildren.get(0) && childStatus.isRunning()) {
74
			// is first child, and is running -> copy status
75
			internalSetChildrenStatus(childStatus);
76
			return;
77
		}
78
		TestElement lastChild= (TestElement) fChildren.get(childCount - 1);
79
		if (child == lastChild) {
80
			if (childStatus.isDone()) {
81
				// all children done, collect cumulative status
82
				internalSetChildrenStatus(getCumulatedStatus());
83
				return;
84
			}
85
			// go on (child could e.g. be a TestSuiteElement with RUNNING_FAILURE)
86
			
87
		} else 	if (! lastChild.getStatus().isNotRun()) {
88
			// child is not last, but last child has been run -> child has been rerun or is rerunning
89
			internalSetChildrenStatus(getCumulatedStatus());
90
			return;
91
		}
92
		
93
		// finally, set RUNNING_FAILURE/ERROR if child has failed but suite has not failed: 
94
		if (childStatus.isFailure()) {
95
			if (fChildrenStatus == null || ! fChildrenStatus.isErrorOrFailure()) {
96
				internalSetChildrenStatus(Status.RUNNING_FAILURE);
97
				return;
98
			}
99
		} else if (childStatus.isError()) {
100
			if (fChildrenStatus == null || ! fChildrenStatus.isError()) {
101
				internalSetChildrenStatus(Status.RUNNING_ERROR);
102
				return;
103
			}
104
		}
105
	}
106
107
	private void internalSetChildrenStatus(Status status) {
108
		if (fChildrenStatus == status)
109
			return;
110
		fChildrenStatus= status;
111
		TestSuiteElement parent= getParent();
112
		if (parent != null)
113
			parent.childChangedStatus(this, getStatus());
114
	}
115
65
}
116
}
(-)src/org/eclipse/jdt/internal/junit/model/TestElement.java (-2 / +5 lines)
Lines 155-163 Link Here
155
		fParent= parent;
155
		fParent= parent;
156
		fId= id;
156
		fId= id;
157
		fTestName= testName;
157
		fTestName= testName;
158
		fStatus= Status.NOT_RUN;
158
		if (parent != null)
159
		if (parent != null)
159
			parent.addChild(this);
160
			parent.addChild(this);
160
		fStatus= Status.NOT_RUN;
161
	}
161
	}
162
	
162
	
163
	/**
163
	/**
Lines 183-197 Link Here
183
		//TODO: notify about change?
183
		//TODO: notify about change?
184
		//TODO: multiple errors/failures per test https://bugs.eclipse.org/bugs/show_bug.cgi?id=125296
184
		//TODO: multiple errors/failures per test https://bugs.eclipse.org/bugs/show_bug.cgi?id=125296
185
		fStatus= status;
185
		fStatus= status;
186
		TestSuiteElement parent= getParent();
187
		if (parent != null)
188
			parent.childChangedStatus(this, status);
186
	}
189
	}
187
	
190
	
188
	public void setStatus(Status status, String trace, String expected, String actual) {
191
	public void setStatus(Status status, String trace, String expected, String actual) {
189
		//TODO: notify about change?
192
		//TODO: notify about change?
190
		//TODO: multiple errors/failures per test https://bugs.eclipse.org/bugs/show_bug.cgi?id=125296
193
		//TODO: multiple errors/failures per test https://bugs.eclipse.org/bugs/show_bug.cgi?id=125296
191
		fStatus= status;
192
		fTrace= trace;
194
		fTrace= trace;
193
		fExpected= expected;
195
		fExpected= expected;
194
		fActual= actual;
196
		fActual= actual;
197
		setStatus(status);
195
	}
198
	}
196
199
197
	public Status getStatus() {
200
	public Status getStatus() {

Return to bug 129929