{"action":"created","issue":{"url":"https://api.github.com/repos/cbeust/testng/issues/863","labels_url":"https://api.github.com/repos/cbeust/testng/issues/863/labels{/name}","comments_url":"https://api.github.com/repos/cbeust/testng/issues/863/comments","events_url":"https://api.github.com/repos/cbeust/testng/issues/863/events","html_url":"https://github.com/cbeust/testng/issues/863","id":116171407,"number":863,"title":"Same xmlsuite is added multiple times when tests are run using TestNG.SetXmlSuites method","user":{"login":"virenv","id":6619269,"avatar_url":"https://avatars.githubusercontent.com/u/6619269?v=3","gravatar_id":"","url":"https://api.github.com/users/virenv","html_url":"https://github.com/virenv","followers_url":"https://api.github.com/users/virenv/followers","following_url":"https://api.github.com/users/virenv/following{/other_user}","gists_url":"https://api.github.com/users/virenv/gists{/gist_id}","starred_url":"https://api.github.com/users/virenv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virenv/subscriptions","organizations_url":"https://api.github.com/users/virenv/orgs","repos_url":"https://api.github.com/users/virenv/repos","events_url":"https://api.github.com/users/virenv/events{/privacy}","received_events_url":"https://api.github.com/users/virenv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-10T18:27:05Z","updated_at":"2015-11-11T14:05:54Z","closed_at":null,"body":"@cbeust,\r\n\r\nHere is the description of the problem.\r\n\r\nMy trimmed down run engine code\r\n    \r\n\t\tParser parser = new Parser(\".\\\\CompleteSuite.xml\");\r\n\t\tList<XmlSuite> xmlSuite = null;\r\n\t\ttry {\r\n\t\t\txmlSuite = parser.parseToList();\r\n\t\t} catch (ParserConfigurationException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t} catch (SAXException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t} catch (IOException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\r\n\t\t// List<String> suites = new ArrayList<String>();\r\n\t\tTestNG testng = new TestNG();\r\n\t\tTestListener listner = new TestListener();\r\n\t\ttestng.addListener(listner);\r\n\t\ttestng.addListener(new SuiteListner());\r\n\t\t// suites.add(\".\\\\CompleteSuite.xml\");\r\n\t\ttestng.setXmlSuites(xmlSuite);\r\n\t\t// testng.setTestSuites(suites);\r\n\t\ttestng.setParallel(\"parallel\");\r\n\t\ttestng.setSuiteThreadPoolSize(5);\r\n\t\ttestng.setDataProviderThreadCount(5);\r\n\t\ttestng.setOutputDirectory(\"path to output\");\r\n\t\ttestng.run();\r\n\r\nMy suite XML looks like this\r\n\n```\n<suite name=\"suite of suites\">\r\n    <suite-files>\r\n        <suite-file path=\"TestNG.xml\" />\r\n        <suite-file path=\"TestNG2.xml\" />\r\n    </suite-files>\r\n</suite>\n```\n\r\nyou can have any two testNG suites as mentioned here. \r\n\r\n**Problem**\r\nWhen you run this code you will get an exception stating \r\n*Two suites cannot have the same name: Suite2*\r\n\r\nThis exception will come even if you have two different suite names. The reason is because of this code in **initializeSuitesAndJarFile** of TestNG class\r\n    \r\n        for (String suiteFile : s.getSuiteFiles()) {\r\n            try {\r\n                Collection<XmlSuite> childSuites = getParser(suiteFile).parse();\r\n                for (XmlSuite cSuite : childSuites){\r\n                    cSuite.setParentSuite(s);\r\n                    s.getChildSuites().add(cSuite);\r\n                }\r\n            }\r\n\r\nhere do we really need adding of same suite back to the parent? s.getChildSuites().add(cSuite);\r\n\r\nVirender\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cbeust/testng/issues/comments/155792311","html_url":"https://github.com/cbeust/testng/issues/863#issuecomment-155792311","issue_url":"https://api.github.com/repos/cbeust/testng/issues/863","id":155792311,"user":{"login":"virenv","id":6619269,"avatar_url":"https://avatars.githubusercontent.com/u/6619269?v=3","gravatar_id":"","url":"https://api.github.com/users/virenv","html_url":"https://github.com/virenv","followers_url":"https://api.github.com/users/virenv/followers","following_url":"https://api.github.com/users/virenv/following{/other_user}","gists_url":"https://api.github.com/users/virenv/gists{/gist_id}","starred_url":"https://api.github.com/users/virenv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virenv/subscriptions","organizations_url":"https://api.github.com/users/virenv/orgs","repos_url":"https://api.github.com/users/virenv/repos","events_url":"https://api.github.com/users/virenv/events{/privacy}","received_events_url":"https://api.github.com/users/virenv/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T14:05:54Z","updated_at":"2015-11-11T14:05:54Z","body":"Hi juherr,\r\n\r\nI am on testng 6.9.4. I would have tried the latest version but saw that this part of the code hasn't changed."}}