1010import org .testng .annotations .DataProvider ;
1111import org .testng .annotations .Test ;
1212import org .testng .xml .XmlSuite ;
13+ import test .configurationfailurepolicy .issue2731 .ConfigFailTestSample ;
1314import testhelper .OutputDirectoryPatch ;
1415
1516public class FailurePolicyTest {
@@ -19,39 +20,39 @@ public class FailurePolicyTest {
1920 public void setupClass (ITestContext testContext ) {
2021 assertEquals (
2122 testContext .getSuite ().getXmlSuite ().getConfigFailurePolicy (),
22- XmlSuite .FailurePolicy .CONTINUE );
23+ XmlSuite .FailurePolicy .SKIP );
2324 }
2425
2526 @ DataProvider (name = "dp" )
2627 public Object [][] getData () {
2728 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
4438 },
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 },
5556 };
5657 }
5758
@@ -67,7 +68,7 @@ public void confFailureTest(
6768 testng .setOutputDirectory (OutputDirectoryPatch .getOutputDirectory ());
6869 testng .setTestClasses (classesUnderTest );
6970 testng .addListener (tla );
70- testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .CONTINUE );
71+ testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .SKIP );
7172 testng .run ();
7273
7374 verify (tla , configurationFailures , configurationSkips , skippedTests );
@@ -83,7 +84,7 @@ public void confFailureTestInvolvingGroups() {
8384 testng .setOutputDirectory (OutputDirectoryPatch .getOutputDirectory ());
8485 testng .setTestClasses (classesUnderTest );
8586 testng .addListener (tla );
86- testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .CONTINUE );
87+ testng .setConfigFailurePolicy (XmlSuite .FailurePolicy .SKIP );
8788 testng .setGroups ("group1" );
8889 testng .run ();
8990 verify (tla , 1 , 3 , 1 );
@@ -93,76 +94,39 @@ public void confFailureTestInvolvingGroups() {
9394 public void commandLineTest_policyAsSkip () {
9495 String [] argv =
9596 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 ()
104105 };
105106 TestListenerAdapter tla = new TestListenerAdapter ();
106107 TestNG .privateMain (argv , tla );
107108
108109 verify (tla , 1 , 1 , 2 );
109110 }
110111
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-
130112 @ Test
131113 public void commandLineTestWithXMLFile_policyAsSkip () {
132114 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" )
141123 };
142124 TestListenerAdapter tla = new TestListenerAdapter ();
143125 TestNG .privateMain (argv , tla );
144126
145127 verify (tla , 1 , 1 , 2 );
146128 }
147129
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-
166130 private void verify (
167131 TestListenerAdapter tla ,
168132 int configurationFailures ,
0 commit comments