1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.util;
import junit.framework.TestCase;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.testing.run.IRun;
import org.aspectj.testing.run.IRunStatus;
import org.aspectj.testing.run.RunStatus;
import org.aspectj.testing.run.Runner;
/**
*
*/
public class BridgeUtilTest extends TestCase {
public BridgeUtilTest(String name) {
super(name);
}
public void testChildString() {
String expect;
String id;
id = "run status identifier";
expect = "PASS " + id + " 0 tests";
checkChildString(id, 0, 0, 0, 0, expect);
expect = "PASS " + id + " 2 tests (2 skipped)";
checkChildString(id, 2, 0, 0, 0, expect);
expect = "PASS " + id + " 3 tests (1 skipped, 2 passed)";
checkChildString(id, 1, 0, 0, 2, expect);
expect = "FAIL " + id + " 3 tests (1 skipped, 2 failed)";
checkChildString(id, 1, 0, 2, 0, expect);
expect = "FAIL " + id + " 6 tests (1 skipped, 2 failed, 3 passed)";
checkChildString(id, 1, 0, 2, 3, expect);
expect = "FAIL " + id + " 1 tests (1 failed)";
checkChildString(id, 0, 0, 1, 0, expect);
expect = "FAIL " + id + " 4 tests (1 failed, 3 passed)";
checkChildString(id, 0, 0, 1, 3, expect);
expect = "PASS " + id + " 1 tests (1 passed)";
checkChildString(id, 0, 0, 0, 1, expect);
// "incomplete" variants
expect = "PASS " + id + " 5 tests (5 incomplete)";
checkChildString(id, 0, 5, 0, 0, expect);
expect = "PASS " + id + " 7 tests (2 skipped, 5 incomplete)";
checkChildString(id, 2, 5, 0, 0, expect);
expect = "PASS " + id + " 8 tests (1 skipped, 5 incomplete, 2 passed)";
checkChildString(id, 1, 5, 0, 2, expect);
expect = "FAIL " + id + " 8 tests (1 skipped, 5 incomplete, 2 failed)";
checkChildString(id, 1, 5, 2, 0, expect);
expect = "FAIL " + id + " 11 tests (1 skipped, 5 incomplete, 2 failed, 3 passed)";
checkChildString(id, 1, 5, 2, 3, expect);
expect = "FAIL " + id + " 6 tests (5 incomplete, 1 failed)";
checkChildString(id, 0, 5, 1, 0, expect);
expect = "FAIL " + id + " 9 tests (5 incomplete, 1 failed, 3 passed)";
checkChildString(id, 0, 5, 1, 3, expect);
expect = "PASS " + id + " 6 tests (5 incomplete, 1 passed)";
checkChildString(id, 0, 5, 0, 1, expect);
}
void checkChildString(String id, int numSkips, int numIncomplete, int numFails, int numPasses,
String expected) {
Runner runner = new Runner();
MessageHandler holder = new MessageHandler();
RunStatus status = new RunStatus(holder, runner);
status.setIdentifier(id);
status.start();
final IRun failer = new IRun() {
public boolean run(IRunStatus status) { return false; }
};
final IRun passer = new IRun() {
public boolean run(IRunStatus status) { return true; }
};
final Object result = (numFails > 0 ? IRunStatus.FAIL : IRunStatus.PASS);
while (numFails-- > 0) {
runner.runChild(failer,status, null, null);
}
while (numPasses-- > 0) {
runner.runChild(passer,status, null, null);
}
status.finish(result);
String actual = BridgeUtil.childString(status, numSkips, numIncomplete);
String label = " expected \"" + expected + "\" got \"" + actual + "\"";
assertTrue(label, expected.equals(actual));
}
}
|