1
1
package org .junit .rules ;
2
2
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
5
+
3
6
import org .junit .internal .AssumptionViolatedException ;
4
7
import org .junit .runner .Description ;
5
8
import org .junit .runners .model .MultipleFailureException ;
6
9
import org .junit .runners .model .Statement ;
7
10
8
- import java .util .ArrayList ;
9
- import java .util .List ;
10
-
11
11
/**
12
12
* TestWatcher is a base class for Rules that take note of the testing
13
13
* action, without modifying it. For example, this class will keep a log of each
14
14
* passing and failing test:
15
- * <p/>
15
+ *
16
16
* <pre>
17
17
* public static class WatchmanTest {
18
- * private static String watchedLog;
18
+ * private static String watchedLog;
19
19
*
20
- * @Rule
21
- * public TestWatcher watchman= new TestWatcher() {
22
- * @Override
23
- * protected void failed(Throwable e, Description description) {
24
- * watchedLog+= description + "\n";
25
- * }
20
+ * @Rule
21
+ * public TestWatcher watchman= new TestWatcher() {
22
+ * @Override
23
+ * protected void failed(Throwable e, Description description) {
24
+ * watchedLog+= description + "\n";
25
+ * }
26
26
*
27
- * @Override
28
- * protected void succeeded(Description description) {
29
- * watchedLog+= description + " " + "success!\n";
27
+ * @Override
28
+ * protected void succeeded(Description description) {
29
+ * watchedLog+= description + " " + "success!\n";
30
30
* }
31
31
* };
32
32
*
33
- * @Test
34
- * public void fails() {
35
- * fail();
36
- * }
33
+ * @Test
34
+ * public void fails() {
35
+ * fail();
36
+ * }
37
37
*
38
- * @Test
39
- * public void succeeds() {
38
+ * @Test
39
+ * public void succeeds() {
40
40
* }
41
41
* }
42
42
* </pre>
@@ -70,7 +70,7 @@ public void evaluate() throws Throwable {
70
70
}
71
71
72
72
private void succeededQuietly (Description description ,
73
- List <Throwable > errors ) {
73
+ List <Throwable > errors ) {
74
74
try {
75
75
succeeded (description );
76
76
} catch (Throwable t ) {
@@ -79,7 +79,7 @@ private void succeededQuietly(Description description,
79
79
}
80
80
81
81
private void failedQuietly (Throwable t , Description description ,
82
- List <Throwable > errors ) {
82
+ List <Throwable > errors ) {
83
83
try {
84
84
failed (t , description );
85
85
} catch (Throwable t1 ) {
@@ -88,7 +88,7 @@ private void failedQuietly(Throwable t, Description description,
88
88
}
89
89
90
90
private void skippedQuietly (AssumptionViolatedException e , Description description ,
91
- List <Throwable > errors ) {
91
+ List <Throwable > errors ) {
92
92
try {
93
93
skipped (e , description );
94
94
} catch (Throwable t ) {
@@ -97,7 +97,7 @@ private void skippedQuietly(AssumptionViolatedException e, Description descripti
97
97
}
98
98
99
99
private void startingQuietly (Description description ,
100
- List <Throwable > errors ) {
100
+ List <Throwable > errors ) {
101
101
try {
102
102
starting (description );
103
103
} catch (Throwable t ) {
@@ -106,7 +106,7 @@ private void startingQuietly(Description description,
106
106
}
107
107
108
108
private void finishedQuietly (Description description ,
109
- List <Throwable > errors ) {
109
+ List <Throwable > errors ) {
110
110
try {
111
111
finished (description );
112
112
} catch (Throwable t ) {
0 commit comments