1 package org.apache.maven.surefire.its;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
23 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
24 import org.junit.Test;
25
26
27
28
29
30
31
32 public class JUnit48TestCategoriesIT
33 extends SurefireJUnit4IntegrationTestCase
34 {
35 @Test
36 public void testCategoriesAB()
37 {
38 runAB( unpacked() );
39 }
40
41 @Test
42 public void testCategoriesABForkAlways()
43 {
44 runAB( unpacked().forkAlways() );
45 }
46
47 @Test
48 public void testCategoriesACFullyQualifiedClassName()
49 {
50 runACFullyQualifiedClassName( unpacked() );
51 }
52
53 @Test
54 public void testCategoriesACFullyQualifiedClassNameForkAlways()
55 {
56 runACFullyQualifiedClassName( unpacked().forkAlways() );
57 }
58
59 @Test
60 public void testCategoriesACClassNameSuffix()
61 {
62 runACClassNameSuffix( unpacked() );
63 }
64
65 @Test
66 public void testCategoriesACClassNameSuffixForkAlways()
67 {
68 runACClassNameSuffix( unpacked().forkAlways() );
69 }
70
71 @Test
72 public void testCategoriesBadCategory()
73 {
74 runBadCategory( unpacked() );
75 }
76
77 @Test
78 public void testBadCategoryForkAlways()
79 {
80 runBadCategory( unpacked().forkAlways() );
81 }
82
83 private static void runAB( SurefireLauncher unpacked )
84 {
85 unpacked.executeTest()
86 .verifyErrorFreeLog()
87 .assertTestSuiteResults( 3, 0, 0, 0 )
88 .verifyTextInLog( "catA: 1" )
89 .verifyTextInLog( "catB: 1" )
90 .verifyTextInLog( "catC: 0" )
91 .verifyTextInLog( "catNone: 0" );
92 }
93
94 private static void runACClassNameSuffix( SurefireLauncher unpacked )
95 {
96 unpacked.groups( "CategoryA,CategoryC" )
97 .executeTest()
98 .verifyErrorFreeLog()
99 .assertTestSuiteResults( 6, 0, 0, 0 )
100 .verifyTextInLog( "catA: 1" )
101 .verifyTextInLog( "catB: 0" )
102 .verifyTextInLog( "catC: 1" )
103 .verifyTextInLog( "catNone: 0" )
104 .verifyTextInLog( "mA: 1" )
105
106
107 .verifyTextInLog( "mB: 1" )
108
109 .verifyTextInLog( "mC: 1" )
110 .verifyTextInLog( "CatNone: 1" );
111 }
112
113 private static void runACFullyQualifiedClassName( SurefireLauncher unpacked )
114 {
115 unpacked.groups( "junit4.CategoryA,junit4.CategoryC" )
116 .executeTest()
117 .verifyErrorFreeLog()
118 .assertTestSuiteResults( 6, 0, 0, 0 )
119 .verifyTextInLog( "catA: 1" )
120 .verifyTextInLog( "catB: 0" )
121 .verifyTextInLog( "catC: 1" )
122 .verifyTextInLog( "catNone: 0" )
123 .verifyTextInLog( "mA: 1" )
124
125
126 .verifyTextInLog( "mB: 1" )
127
128 .verifyTextInLog( "mC: 1" )
129 .verifyTextInLog( "CatNone: 1" );
130 }
131
132 private static void runBadCategory( SurefireLauncher unpacked )
133 {
134 unpacked.failIfNoTests( false )
135 .groups( "BadCategory" )
136 .executeTest()
137 .verifyErrorFreeLog();
138 }
139
140 private SurefireLauncher unpacked()
141 {
142 return unpack( "/junit48-categories" );
143
144 }
145 }