2222import org .testng .internal .WrappedTestNGMethod ;
2323import org .testng .reporters .RuntimeBehavior ;
2424import org .w3c .dom .Document ;
25+ import org .w3c .dom .Node ;
2526import test .SimpleBaseTest ;
2627import test .reports .issue2171 .TestClassExample ;
28+ import test .reports .issue2886 .HydeTestSample ;
29+ import test .reports .issue2886 .JekyllTestSample ;
2730import test .simple .SimpleSample ;
2831
2932public class XmlReporterTest extends SimpleBaseTest {
@@ -60,7 +63,7 @@ public void ensureStackTraceHasLineFeedsTest() throws Exception {
6063
6164 @ Test (description = "GITHUB-2171" )
6265 public void ensureCustomisationOfReportIsSupported () throws Exception {
63- File file = runTest (TestClassExample . class , "issue_2171.xml" );
66+ File file = runTest ("issue_2171.xml" , null , TestClassExample . class );
6467 DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
6568 DocumentBuilder builder = factory .newDocumentBuilder ();
6669 Document doc = builder .parse (file );
@@ -74,7 +77,6 @@ public void ensureCustomisationOfReportIsSupported() throws Exception {
7477 public void ensureReportGenerationWhenTestMethodIsWrappedWithWrappedTestNGMethod () {
7578 File file =
7679 runTest (
77- SimpleSample .class ,
7880 testng ->
7981 testng .setMethodInterceptor (
8082 (methods , context ) ->
@@ -88,19 +90,34 @@ public void ensureReportGenerationWhenTestMethodIsWrappedWithWrappedTestNGMethod
8890 assertThat (file .exists ()).isTrue ();
8991 }
9092
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 ();
93110 }
94111
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 );
97114 }
98115
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 );
101118 }
102119
103- private static File runTest (Class <?> clazz , String fileName , Consumer <TestNG > customizer ) {
120+ private static File runTest (String fileName , Consumer <TestNG > customizer , Class <?>... clazz ) {
104121 String suiteName = UUID .randomUUID ().toString ();
105122 File fileLocation = createDirInTempDir (suiteName );
106123 TestNG testng = create (fileLocation .toPath (), clazz );
0 commit comments