1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.surefire.its.jiras;
20
21 import org.apache.maven.it.VerificationException;
22 import org.apache.maven.surefire.its.fixture.OutputValidator;
23 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
24 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
25 import org.junit.Test;
26
27 import static org.hamcrest.Matchers.containsString;
28 import static org.hamcrest.Matchers.is;
29
30
31
32
33
34
35 public class Surefire995CategoryInheritanceIT extends SurefireJUnit4IntegrationTestCase {
36
37 @Test
38 public void negativeTestShouldRunAllCategories() {
39 unpack().setTestToRun("Special*Test").executeTest().verifyErrorFree(3);
40 }
41
42 @Test
43 public void junit411ShouldRunExplicitCategory() {
44 final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests")
45 .sysProp("version.junit", "4.11")
46 .executeTest();
47
48 outputValidator.verifyErrorFree(1).verifyTextInLog("CategorizedTest#a");
49 }
50
51 @Test
52 public void junit411ShouldExcludeExplicitCategory() {
53 final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-excluded-categories")
54 .sysProp("version.junit", "4.11")
55 .executeTest();
56
57
58 outputValidator.verifyTextInLog("SpecialCategorizedTest#b").verifyErrorFree(16);
59 }
60
61 @Test
62 public void junit412ShouldRunInheritedCategory() {
63 unpack().setTestToRun("Special*Test")
64 .addGoal("-Ppositive-tests")
65 .executeTest()
66 .verifyErrorFree(2);
67 }
68
69 @Test
70 public void junit412ShouldExcludeInheritedCategory() {
71 unpack().setTestToRun("Special*Test")
72 .addGoal("-Ppositive-tests-excluded-categories")
73 .executeTest()
74 .verifyErrorFree(1)
75 .verifyTextInLog("SpecialNonCategoryTest#test");
76 }
77
78 @Test
79 public void junit411ShouldIgnoreInheritedCategories() throws VerificationException {
80
81 final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-included-and-excluded-categories")
82 .sysProp("version.junit", "4.11")
83
84 .setGroups("jiras.surefire955.group.marker.CategoryB")
85
86 .executeTest();
87
88
89 outputValidator
90
91 .verifyTextInLog("Running jiras.surefire955.group.BBCTest")
92 .verifyTextInLog("BBCTest#bbc")
93 .verifyTextInLog("AbstractBCTest#pb")
94 .verifyTextInLog("AbstractCTest#pc")
95 .verifyTextInLog("Running jiras.surefire955.group.BTest")
96 .verifyTextInLog("BTest#b")
97
98 .assertThatLogLine(containsString("BCTest#bc"), is(0))
99 .assertThatLogLine(containsString("ABCTest#abc"), is(0))
100 .verifyErrorFree(4);
101 }
102
103 @Test
104 public void junit412ShouldExecuteInheritedCategories() {
105
106 final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-included-and-excluded-categories")
107 .sysProp("version.junit", "4.12")
108
109 .setGroups("jiras.surefire955.group.marker.CategoryB")
110
111 .executeTest();
112
113
114 outputValidator
115 .verifyErrorFree(10)
116 .verifyTextInLog("Running jiras.surefire955.group.BBCTest")
117
118 .verifyTextInLog("BBCTest#bbc")
119 .verifyTextInLog("AbstractBCTest#pb")
120 .verifyTextInLog("AbstractCTest#pc")
121 .verifyTextInLog("Running jiras.surefire955.group.BTest")
122 .verifyTextInLog("BTest#b")
123
124 .verifyTextInLog("Running jiras.surefire955.group.ABCTest")
125
126 .verifyTextInLog("ABCTest#abc")
127 .verifyTextInLog("AbstractBCTest#pb")
128 .verifyTextInLog("AbstractCTest#pc")
129 .verifyTextInLog("Running jiras.surefire955.group.BCTest")
130
131 .verifyTextInLog("BCTest#bc")
132 .verifyTextInLog("AbstractBCTest#pb")
133 .verifyTextInLog("AbstractCTest#pc");
134 }
135
136 private SurefireLauncher unpack() {
137 return unpack("surefire-995-categoryInheritance");
138 }
139 }