1 package org.apache.maven.surefire.common.junit4;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import junit.framework.TestCase;
22 import org.junit.Ignore;
23 import org.junit.Test;
24 import org.junit.runner.Description;
25
26
27
28
29 public class JUnit4Reflector40Test
30 extends TestCase
31 {
32 public void testGetAnnotatedIgnore()
33 {
34 Description desc = Description.createTestDescription( IgnoreWithDescription.class, "testSomething2" );
35 Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore( desc );
36 assertNull( annotatedIgnore );
37 }
38
39 private static final String reason = "Ignorance is bliss";
40
41 public static class IgnoreWithDescription
42 {
43
44 @Test
45 @Ignore( reason )
46 public void testSomething2()
47 {
48 }
49 }
50
51 public void testCreateIgnored()
52 {
53 Ignore ignore = JUnit4Reflector.createIgnored( "error" );
54 assertNotNull( ignore );
55 assertNotNull( ignore.value() );
56 assertEquals( "error", ignore.value() );
57 }
58
59 public void testCreateDescription()
60 {
61 Ignore ignore = JUnit4Reflector.createIgnored( "error" );
62 Description description = JUnit4Reflector.createDescription( "exception", ignore );
63 assertEquals( "exception", description.getDisplayName() );
64 assertEquals( "exception", description.toString() );
65 assertEquals( 0, description.getChildren().size() );
66
67 Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore( description );
68 assertNull( annotatedIgnore );
69 }
70
71 public void testCreatePureDescription()
72 {
73 Description description = JUnit4Reflector.createDescription( "exception" );
74 assertEquals( "exception", description.getDisplayName() );
75 assertEquals( "exception", description.toString() );
76 assertEquals( 0, description.getChildren().size() );
77 }
78 }
79
80