@@ -162,7 +162,7 @@ public XmlSuite constructXmlAndExecuteTestCaseAtRuntime(List<String> testCases,
162162 XmlSuite suite = new XmlSuite ();
163163 suite .setName (suiteName );
164164 XmlTest test = new XmlTest (suite );
165- test .setName ("regression" );
165+ test .setName (category );
166166 suite .setThreadCount (deviceCount );
167167 suite .setDataProviderThreadCount (deviceCount );
168168 suite .setVerbose (2 );
@@ -172,19 +172,21 @@ public XmlSuite constructXmlAndExecuteTestCaseAtRuntime(List<String> testCases,
172172 suite .setListeners (listeners );
173173 for (Map .Entry <String , List <Method >> mapElement : methods .entrySet ()) {
174174 XmlClass xmlClass = new XmlClass (mapElement .getKey ());
175- for ( String testName : testCases ) {
176- for (Method methodName : mapElement .getValue ()) {
177- if ( methodName . getName (). equalsIgnoreCase ( testName )) {
178- List < XmlInclude > includedMethodsList = new ArrayList <>();
179- XmlInclude includedTestMethod = new XmlInclude (testName );
175+ List < XmlInclude > includedMethodsList = new ArrayList <>();
176+ for (Method methodName : mapElement .getValue ()) {
177+ for ( String testCase : testCases ) {
178+ if ( methodName . getName (). equalsIgnoreCase ( testCase )) {
179+ XmlInclude includedTestMethod = new XmlInclude (testCase );
180180 includedMethodsList .add (includedTestMethod );
181- xmlClass .setIncludedMethods (includedMethodsList );
182- classes .add (xmlClass );
181+ break ;
183182 }
184183 }
185184 }
185+ if (!includedMethodsList .isEmpty ()) {
186+ xmlClass .setIncludedMethods (includedMethodsList );
187+ classes .add (xmlClass );
188+ }
186189 }
187-
188190 test .setXmlClasses (classes );
189191 writeTestNGFile (suite );
190192 return suite ;
0 commit comments