|
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 |
} |