1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.surefire.common.junit3;
20
21 import junit.framework.TestCase;
22 import junit.framework.TestResult;
23
24
25
26
27 public class JUnit3TestCheckerTest extends TestCase {
28 private final JUnit3TestChecker jUnit3TestChecker =
29 new JUnit3TestChecker(this.getClass().getClassLoader());
30
31 public void testValidJunit4Annotated() {
32 assertTrue(jUnit3TestChecker.accept(JUnit3TestCheckerTest.class));
33 }
34
35 public void testValidJunit4itsAJunit3Test() {
36 assertTrue(jUnit3TestChecker.accept(AlsoValid.class));
37 }
38
39 public void testValidJunitSubclassWithoutOwnTestmethods() {
40 assertTrue(jUnit3TestChecker.accept(SubClassWithoutOwnTestMethods.class));
41 }
42
43 public void testInvalidTest() {
44 assertFalse(jUnit3TestChecker.accept(NotValidTest.class));
45 }
46
47 public void testDontAcceptAbstractClasses() {
48 assertFalse(jUnit3TestChecker.accept(BaseClassWithTest.class));
49 }
50
51 public void testSuiteOnlyTest() {
52 assertTrue(jUnit3TestChecker.accept(SuiteOnlyTest.class));
53 }
54
55 public void testCustomSuiteOnlyTest() {
56 assertTrue(jUnit3TestChecker.accept(CustomSuiteOnlyTest.class));
57 }
58
59 public void testIinnerClassNotAutomaticallyTc() {
60 assertTrue(jUnit3TestChecker.accept(NestedTC.class));
61 assertFalse(jUnit3TestChecker.accept(NestedTC.Inner.class));
62 }
63
64
65
66
67 public static class AlsoValid extends TestCase {
68 public void testSomething() {}
69 }
70
71
72
73
74 public static class SuiteOnlyTest {
75 public static junit.framework.Test suite() {
76 return null;
77 }
78 }
79
80
81
82
83 public static class CustomSuiteOnlyTest {
84 public static MySuite2 suite() {
85 return null;
86 }
87 }
88
89
90
91
92 public static class MySuite2 implements junit.framework.Test {
93 @Override
94 public int countTestCases() {
95 return 0;
96 }
97
98 @Override
99 public void run(TestResult testResult) {}
100 }
101
102
103
104
105 public static class NotValidTest {
106 public void testSomething() {}
107 }
108
109
110
111
112 public abstract static class BaseClassWithTest extends TestCase {
113 public void testWeAreAlsoATest() {}
114 }
115
116
117
118
119 public static class SubClassWithoutOwnTestMethods extends BaseClassWithTest {}
120
121 class NestedTC extends TestCase {
122 public class Inner {}
123 }
124 }