10
10
import org .testng .annotations .DataProvider ;
11
11
import org .testng .annotations .Test ;
12
12
import org .testng .xml .XmlSuite ;
13
+ import test .configurationfailurepolicy .issue2731 .ConfigFailTestSample ;
13
14
import testhelper .OutputDirectoryPatch ;
14
15
15
16
public class FailurePolicyTest {
@@ -19,39 +20,39 @@ public class FailurePolicyTest {
19
20
public void setupClass (ITestContext testContext ) {
20
21
assertEquals (
21
22
testContext .getSuite ().getXmlSuite ().getConfigFailurePolicy (),
22
- XmlSuite .FailurePolicy .CONTINUE );
23
+ XmlSuite .FailurePolicy .SKIP );
23
24
}
24
25
25
26
@ DataProvider (name = "dp" )
26
27
public Object [][] getData () {
27
28
return new Object [][] {
28
- // params - confFail, confSkip, skippedTests
29
- new Object [] {new Class [] {ClassWithFailedBeforeClassMethod .class }, 1 , 1 , 1 },
30
- new Object [] {new Class [] {ClassWithFailedBeforeClassMethodAndAfterClass .class }, 1 , 1 , 1 },
31
- new Object [] {new Class [] {ClassWithFailedBeforeMethodAndMultipleTests .class }, 2 , 0 , 2 },
32
- new Object [] {
33
- new Class [] {ClassWithFailedBeforeClassMethodAndBeforeMethodAfterMethodAfterClass .class },
34
- 1 ,
35
- 3 ,
36
- 1
37
- },
38
- new Object [] {new Class [] {ClassWithFailedBeforeMethodAndMultipleInvocations .class }, 4 , 0 , 4 },
39
- new Object [] {new Class [] {ExtendsClassWithFailedBeforeMethod .class }, 2 , 2 , 2 },
40
- new Object [] {new Class [] {ExtendsClassWithFailedBeforeClassMethod .class }, 1 , 2 , 2 },
41
- new Object [] {
42
- new Class [] {
43
- ClassWithFailedBeforeClassMethod .class , ExtendsClassWithFailedBeforeClassMethod .class
29
+ // params - confFail, confSkip, skippedTests
30
+ new Object [] {new Class [] {ClassWithFailedBeforeClassMethod .class }, 1 , 1 , 1 },
31
+ new Object [] {new Class [] {ClassWithFailedBeforeClassMethodAndAfterClass .class }, 1 , 1 , 1 },
32
+ new Object [] {new Class [] {ClassWithFailedBeforeMethodAndMultipleTests .class }, 2 , 0 , 2 },
33
+ new Object [] {
34
+ new Class [] {ClassWithFailedBeforeClassMethodAndBeforeMethodAfterMethodAfterClass .class },
35
+ 1 ,
36
+ 3 ,
37
+ 1
44
38
},
45
- 2 ,
46
- 3 ,
47
- 3
48
- },
49
- new Object [] {new Class [] {ClassWithSkippingBeforeMethod .class }, 0 , 1 , 1 },
50
- new Object [] {new Class [] {FactoryClassWithFailedBeforeMethod .class }, 2 , 0 , 2 },
51
- new Object [] {
52
- new Class [] {FactoryClassWithFailedBeforeMethodAndMultipleInvocations .class }, 8 , 0 , 8
53
- },
54
- new Object [] {new Class [] {FactoryClassWithFailedBeforeClassMethod .class }, 2 , 2 , 2 },
39
+ new Object [] {new Class [] {ClassWithFailedBeforeMethodAndMultipleInvocations .class }, 4 , 0 , 4 },
40
+ new Object [] {new Class [] {ExtendsClassWithFailedBeforeMethod .class }, 2 , 2 , 2 },
41
+ new Object [] {new Class [] {ExtendsClassWithFailedBeforeClassMethod .class }, 1 , 2 , 2 },
42
+ new Object [] {
43
+ new Class [] {
44
+ ClassWithFailedBeforeClassMethod .class , ExtendsClassWithFailedBeforeClassMethod .class
45
+ },
46
+ 2 ,
47
+ 3 ,
48
+ 3
49
+ },
50
+ new Object [] {new Class [] {ClassWithSkippingBeforeMethod .class }, 0 , 1 , 1 },
51
+ new Object [] {new Class [] {FactoryClassWithFailedBeforeMethod .class }, 2 , 0 , 2 },
52
+ new Object [] {
53
+ new Class [] {FactoryClassWithFailedBeforeMethodAndMultipleInvocations .class }, 8 , 0 , 8
54
+ },
55
+ new Object [] {new Class [] {FactoryClassWithFailedBeforeClassMethod .class }, 2 , 2 , 2 },
55
56
};
56
57
}
57
58
@@ -67,7 +68,7 @@ public void confFailureTest(
67
68
testng .setOutputDirectory (OutputDirectoryPatch .getOutputDirectory ());
68
69
testng .setTestClasses (classesUnderTest );
69
70
testng .addListener (tla );
70
- testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .CONTINUE );
71
+ testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .SKIP );
71
72
testng .run ();
72
73
73
74
verify (tla , configurationFailures , configurationSkips , skippedTests );
@@ -83,7 +84,7 @@ public void confFailureTestInvolvingGroups() {
83
84
testng .setOutputDirectory (OutputDirectoryPatch .getOutputDirectory ());
84
85
testng .setTestClasses (classesUnderTest );
85
86
testng .addListener (tla );
86
- testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .CONTINUE );
87
+ testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .SKIP );
87
88
testng .setGroups ("group1" );
88
89
testng .run ();
89
90
verify (tla , 1 , 3 , 1 );
@@ -93,76 +94,39 @@ public void confFailureTestInvolvingGroups() {
93
94
public void commandLineTest_policyAsSkip () {
94
95
String [] argv =
95
96
new String [] {
96
- "-log" ,
97
- "0" ,
98
- "-d" ,
99
- OutputDirectoryPatch .getOutputDirectory (),
100
- "-configfailurepolicy" ,
101
- "skip" ,
102
- "-testclass" ,
103
- ClassWithFailedBeforeMethodAndMultipleTests .class .getCanonicalName ()
97
+ "-log" ,
98
+ "0" ,
99
+ "-d" ,
100
+ OutputDirectoryPatch .getOutputDirectory (),
101
+ "-configfailurepolicy" ,
102
+ "skip" ,
103
+ "-testclass" ,
104
+ ClassWithFailedBeforeMethodAndMultipleTests .class .getCanonicalName ()
104
105
};
105
106
TestListenerAdapter tla = new TestListenerAdapter ();
106
107
TestNG .privateMain (argv , tla );
107
108
108
109
verify (tla , 1 , 1 , 2 );
109
110
}
110
111
111
- @ Test
112
- public void commandLineTest_policyAsContinue () {
113
- String [] argv =
114
- new String [] {
115
- "-log" ,
116
- "0" ,
117
- "-d" ,
118
- OutputDirectoryPatch .getOutputDirectory (),
119
- "-configfailurepolicy" ,
120
- "continue" ,
121
- "-testclass" ,
122
- ClassWithFailedBeforeMethodAndMultipleTests .class .getCanonicalName ()
123
- };
124
- TestListenerAdapter tla = new TestListenerAdapter ();
125
- TestNG .privateMain (argv , tla );
126
-
127
- verify (tla , 2 , 0 , 2 );
128
- }
129
-
130
112
@ Test
131
113
public void commandLineTestWithXMLFile_policyAsSkip () {
132
114
String [] argv =
133
- new String [] {
134
- "-log" ,
135
- "0" ,
136
- "-d" ,
137
- OutputDirectoryPatch .getOutputDirectory (),
138
- "-configfailurepolicy" ,
139
- "skip" ,
140
- getPathToResource ("testng-configfailure.xml" )
115
+ new String []{
116
+ "-log" ,
117
+ "0" ,
118
+ "-d" ,
119
+ OutputDirectoryPatch .getOutputDirectory (),
120
+ "-configfailurepolicy" ,
121
+ "skip" ,
122
+ getPathToResource ("testng-configfailure.xml" )
141
123
};
142
124
TestListenerAdapter tla = new TestListenerAdapter ();
143
125
TestNG .privateMain (argv , tla );
144
126
145
127
verify (tla , 1 , 1 , 2 );
146
128
}
147
129
148
- @ Test
149
- public void commandLineTestWithXMLFile_policyAsContinue () {
150
- String [] argv =
151
- new String [] {
152
- "-log" ,
153
- "0" ,
154
- "-d" ,
155
- OutputDirectoryPatch .getOutputDirectory (),
156
- "-configfailurepolicy" ,
157
- "continue" ,
158
- getPathToResource ("testng-configfailure.xml" )
159
- };
160
- TestListenerAdapter tla = new TestListenerAdapter ();
161
- TestNG .privateMain (argv , tla );
162
-
163
- verify (tla , 2 , 0 , 2 );
164
- }
165
-
166
130
private void verify (
167
131
TestListenerAdapter tla ,
168
132
int configurationFailures ,
0 commit comments