File tree 5 files changed +48
-0
lines changed
main/java/org/junit/runners/model
5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ public class FrameworkField extends FrameworkMember<FrameworkField> {
16
16
private final Field fField ;
17
17
18
18
FrameworkField (Field field ) {
19
+ if (field == null ) {
20
+ throw new NullPointerException (
21
+ "FrameworkField cannot be created without an underlying field." );
22
+ }
19
23
fField = field ;
20
24
}
21
25
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ public class FrameworkMethod extends FrameworkMember<FrameworkMethod> {
25
25
* Returns a new {@code FrameworkMethod} for {@code method}
26
26
*/
27
27
public FrameworkMethod (Method method ) {
28
+ if (method == null ) {
29
+ throw new NullPointerException (
30
+ "FrameworkMethod cannot be created without an underlying method." );
31
+ }
28
32
fMethod = method ;
29
33
}
30
34
Original file line number Diff line number Diff line change
1
+ package org .junit .runners .model ;
2
+
3
+ import static org .junit .rules .ExpectedException .none ;
4
+ import org .junit .Rule ;
5
+ import org .junit .Test ;
6
+ import org .junit .rules .ExpectedException ;
7
+
8
+ public class FrameworkFieldTest {
9
+ @ Rule
10
+ public final ExpectedException thrown = none ();
11
+
12
+ @ Test
13
+ public void cannotBeCreatedWithoutUnderlyingField () {
14
+ thrown .expect (NullPointerException .class );
15
+ thrown .expectMessage ("FrameworkField cannot be created without an underlying field." );
16
+ new FrameworkField (null );
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package org .junit .runners .model ;
2
+
3
+ import static org .junit .rules .ExpectedException .none ;
4
+ import org .junit .Rule ;
5
+ import org .junit .Test ;
6
+ import org .junit .rules .ExpectedException ;
7
+
8
+ public class FrameworkMethodTest {
9
+ @ Rule
10
+ public final ExpectedException thrown = none ();
11
+
12
+ @ Test
13
+ public void cannotBeCreatedWithoutUnderlyingField () {
14
+ thrown .expect (NullPointerException .class );
15
+ thrown .expectMessage ("FrameworkMethod cannot be created without an underlying method." );
16
+ new FrameworkMethod (null );
17
+ }
18
+ }
Original file line number Diff line number Diff line change 15
15
import org .junit .runner .notification .SynchronizedRunListenerTest ;
16
16
import org .junit .runners .Suite ;
17
17
import org .junit .runners .Suite .SuiteClasses ;
18
+ import org .junit .runners .model .FrameworkFieldTest ;
19
+ import org .junit .runners .model .FrameworkMethodTest ;
18
20
import org .junit .tests .assertion .AssertionTest ;
19
21
import org .junit .tests .assertion .ComparisonFailureTest ;
20
22
import org .junit .tests .assertion .MultipleFailureExceptionTest ;
196
198
JUnitCommandLineParseResultTest .class ,
197
199
FilterFactoriesTest .class ,
198
200
CategoryFilterFactoryTest .class ,
201
+ FrameworkFieldTest .class ,
202
+ FrameworkMethodTest .class ,
199
203
JUnitCoreTest .class
200
204
})
201
205
public class AllTests {
You can’t perform that action at this time.
0 commit comments