File tree 4 files changed +43
-0
lines changed
main/java/org/junit/runners/model
test/java/org/junit/runners/model
4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -77,4 +77,9 @@ public Class<?> getDeclaringClass() {
77
77
public Object get (Object target ) throws IllegalArgumentException , IllegalAccessException {
78
78
return fField .get (target );
79
79
}
80
+
81
+ @ Override
82
+ public String toString () {
83
+ return fField .toString ();
84
+ }
80
85
}
Original file line number Diff line number Diff line change @@ -213,4 +213,9 @@ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
213
213
public List <ParameterSignature > getParameterSignatures () {
214
214
return ParameterSignature .signatures (fMethod );
215
215
}
216
+
217
+ @ Override
218
+ public String toString () {
219
+ return fMethod .toString ();
220
+ }
216
221
}
Original file line number Diff line number Diff line change 1
1
package org .junit .runners .model ;
2
2
3
+ import static org .junit .Assert .assertTrue ;
3
4
import static org .junit .rules .ExpectedException .none ;
5
+
6
+ import java .lang .reflect .Field ;
7
+
4
8
import org .junit .Rule ;
5
9
import org .junit .Test ;
6
10
import org .junit .rules .ExpectedException ;
@@ -15,4 +19,16 @@ public void cannotBeCreatedWithoutUnderlyingField() {
15
19
thrown .expectMessage ("FrameworkField cannot be created without an underlying field." );
16
20
new FrameworkField (null );
17
21
}
22
+
23
+ @ Test
24
+ public void hasToStringWhichPrintsFieldName () throws Exception {
25
+ Field field = ClassWithDummyField .class .getField ("dummyField" );
26
+ FrameworkField frameworkField = new FrameworkField (field );
27
+ assertTrue (frameworkField .toString ().contains ("dummyField" ));
28
+ }
29
+
30
+ private static class ClassWithDummyField {
31
+ @ SuppressWarnings ("unused" )
32
+ public final int dummyField = 0 ;
33
+ }
18
34
}
Original file line number Diff line number Diff line change 1
1
package org .junit .runners .model ;
2
2
3
+ import static org .junit .Assert .assertTrue ;
3
4
import static org .junit .rules .ExpectedException .none ;
5
+
6
+ import java .lang .reflect .Method ;
7
+
4
8
import org .junit .Rule ;
5
9
import org .junit .Test ;
6
10
import org .junit .rules .ExpectedException ;
@@ -15,4 +19,17 @@ public void cannotBeCreatedWithoutUnderlyingField() {
15
19
thrown .expectMessage ("FrameworkMethod cannot be created without an underlying method." );
16
20
new FrameworkMethod (null );
17
21
}
22
+
23
+ @ Test
24
+ public void hasToStringWhichPrintsMethodName () throws Exception {
25
+ Method method = ClassWithDummyMethod .class .getMethod ("dummyMethod" );
26
+ FrameworkMethod frameworkMethod = new FrameworkMethod (method );
27
+ assertTrue (frameworkMethod .toString ().contains ("dummyMethod" ));
28
+ }
29
+
30
+ private static class ClassWithDummyMethod {
31
+ @ SuppressWarnings ("unused" )
32
+ public void dummyMethod () {
33
+ }
34
+ }
18
35
}
You can’t perform that action at this time.
0 commit comments