22
22
import org .testng .internal .WrappedTestNGMethod ;
23
23
import org .testng .reporters .RuntimeBehavior ;
24
24
import org .w3c .dom .Document ;
25
+ import org .w3c .dom .Node ;
25
26
import test .SimpleBaseTest ;
26
27
import test .reports .issue2171 .TestClassExample ;
28
+ import test .reports .issue2886 .HydeTestSample ;
29
+ import test .reports .issue2886 .JekyllTestSample ;
27
30
import test .simple .SimpleSample ;
28
31
29
32
public class XmlReporterTest extends SimpleBaseTest {
@@ -60,7 +63,7 @@ public void ensureStackTraceHasLineFeedsTest() throws Exception {
60
63
61
64
@ Test (description = "GITHUB-2171" )
62
65
public void ensureCustomisationOfReportIsSupported () throws Exception {
63
- File file = runTest (TestClassExample . class , "issue_2171.xml" );
66
+ File file = runTest ("issue_2171.xml" , null , TestClassExample . class );
64
67
DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
65
68
DocumentBuilder builder = factory .newDocumentBuilder ();
66
69
Document doc = builder .parse (file );
@@ -74,7 +77,6 @@ public void ensureCustomisationOfReportIsSupported() throws Exception {
74
77
public void ensureReportGenerationWhenTestMethodIsWrappedWithWrappedTestNGMethod () {
75
78
File file =
76
79
runTest (
77
- SimpleSample .class ,
78
80
testng ->
79
81
testng .setMethodInterceptor (
80
82
(methods , context ) ->
@@ -88,19 +90,34 @@ public void ensureReportGenerationWhenTestMethodIsWrappedWithWrappedTestNGMethod
88
90
assertThat (file .exists ()).isTrue ();
89
91
}
90
92
91
- private static File runTest (Class <?> clazz ) {
92
- return runTest (clazz , RuntimeBehavior .FILE_NAME , null );
93
+ @ Test (description = "GITHUB-2886" )
94
+ public void ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports () throws Exception {
95
+ File file =
96
+ runTest (RuntimeBehavior .FILE_NAME , null , JekyllTestSample .class , HydeTestSample .class );
97
+ DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
98
+ DocumentBuilder builder = factory .newDocumentBuilder ();
99
+ Document doc = builder .parse (file );
100
+ XPath xPath = XPathFactory .newInstance ().newXPath ();
101
+ Node node = (Node ) xPath .compile ("/testng-results" ).evaluate (doc , XPathConstants .NODE );
102
+ int ignored = Integer .parseInt (node .getAttributes ().getNamedItem ("ignored" ).getNodeValue ());
103
+ int total = Integer .parseInt (node .getAttributes ().getNamedItem ("total" ).getNodeValue ());
104
+ int passed = Integer .parseInt (node .getAttributes ().getNamedItem ("passed" ).getNodeValue ());
105
+ int failed = Integer .parseInt (node .getAttributes ().getNamedItem ("failed" ).getNodeValue ());
106
+ assertThat (ignored ).isZero ();
107
+ assertThat (total ).isEqualTo (2 );
108
+ assertThat (passed ).isEqualTo (2 );
109
+ assertThat (failed ).isZero ();
93
110
}
94
111
95
- private static File runTest (Class <?> clazz , Consumer < TestNG > customizer ) {
96
- return runTest (clazz , RuntimeBehavior .FILE_NAME , customizer );
112
+ private static File runTest (Class <?> clazz ) {
113
+ return runTest (RuntimeBehavior .FILE_NAME , null , clazz );
97
114
}
98
115
99
- private static File runTest (Class <?> clazz , String fileName ) {
100
- return runTest (clazz , fileName , null );
116
+ private static File runTest (Consumer < TestNG > customizer ) {
117
+ return runTest (RuntimeBehavior . FILE_NAME , customizer , SimpleSample . class );
101
118
}
102
119
103
- private static File runTest (Class <?> clazz , String fileName , Consumer <TestNG > customizer ) {
120
+ private static File runTest (String fileName , Consumer <TestNG > customizer , Class <?>... clazz ) {
104
121
String suiteName = UUID .randomUUID ().toString ();
105
122
File fileLocation = createDirInTempDir (suiteName );
106
123
TestNG testng = create (fileLocation .toPath (), clazz );
0 commit comments