File tree 2 files changed +10
-4
lines changed
main/java/org/junit/rules
test/java/org/junit/tests/experimental/rules
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -73,12 +73,12 @@ public Object call() throws Exception {
73
73
* Execution continues, but the test will fail at the end if
74
74
* {@code callable} threw an exception.
75
75
*/
76
- public Object checkSucceeds (Callable <Object > callable ) {
76
+ public < T > T checkSucceeds (Callable <T > callable ) {
77
77
try {
78
78
return callable .call ();
79
79
} catch (Throwable e ) {
80
80
addError (e );
81
81
return null ;
82
82
}
83
83
}
84
- }
84
+ }
Original file line number Diff line number Diff line change @@ -84,11 +84,17 @@ public Object call() throws Exception {
84
84
throw new RuntimeException ("first!" );
85
85
}
86
86
});
87
- collector .checkSucceeds (new Callable <Object >() {
88
- public Object call () throws Exception {
87
+ collector .checkSucceeds (new Callable <Integer >() {
88
+ public Integer call () throws Exception {
89
89
throw new RuntimeException ("second!" );
90
90
}
91
91
});
92
+ Integer result = collector .checkSucceeds (new Callable <Integer >() {
93
+ public Integer call () throws Exception {
94
+ return 1 ;
95
+ }
96
+ });
97
+ assertEquals (Integer .valueOf (1 ), result );
92
98
}
93
99
}
94
100
You can’t perform that action at this time.
0 commit comments