1 package test.testng173; 2 3 import java.util.Arrays; 4 5 import org.testng.Assert; 6 import org.testng.ITestResult; 7 import org.testng.TestListenerAdapter; 8 import org.testng.TestNG; 9 import org.testng.annotations.Test; 10 import org.testng.xml.XmlClass; 11 import org.testng.xml.XmlSuite; 12 import org.testng.xml.XmlTest; 13 14 import test.SimpleBaseTest; 15 16 public class TestNG173Test extends SimpleBaseTest { 17 18 @Test orderShouldBePreservedInMethodsWithSameNameAndInDifferentClasses()19 public void orderShouldBePreservedInMethodsWithSameNameAndInDifferentClasses() { 20 TestNG tng = create(); 21 XmlSuite s = createXmlSuite("PreserveOrder"); 22 XmlTest t = new XmlTest(s); 23 24 t.getXmlClasses().add(new XmlClass("test.testng173.ClassA")); 25 t.getXmlClasses().add(new XmlClass("test.testng173.ClassB")); 26 27 t.setPreserveOrder("true"); 28 29 tng.setXmlSuites(Arrays.asList(s)); 30 31 TestListenerAdapter tla = new TestListenerAdapter(); 32 tng.addListener(tla); 33 tng.run(); 34 35 // bug 36 //verifyPassedTests(tla, "test1", "test2", "testX", "test1", "test2"); 37 38 // Proposed fix 39 verifyPassedTests(tla, "test1", "test2", "testX", "test2", "test1"); 40 } 41 42 @Test orderShouldBePreservedInMethodsWithSameNameAndInDifferentClassesAndDifferentPackage()43 public void orderShouldBePreservedInMethodsWithSameNameAndInDifferentClassesAndDifferentPackage() { 44 TestNG tng = create(); 45 XmlSuite s = createXmlSuite("PreserveOrder"); 46 XmlTest t = new XmlTest(s); 47 48 t.getXmlClasses().add(new XmlClass("test.testng173.ClassA")); 49 t.getXmlClasses().add(new XmlClass("test.testng173.anotherpackage.ClassC")); 50 51 t.setPreserveOrder("true"); 52 53 tng.setXmlSuites(Arrays.asList(s)); 54 55 TestListenerAdapter tla = new TestListenerAdapter(); 56 tng.addListener(tla); 57 tng.run(); 58 59 // bug 60 //verifyPassedTests(tla, "test1", "test2", "testX", "test1", "test2"); 61 62 verifyPassedTests(tla, "test1", "test2", "testX", "test2", "test1"); 63 } 64 65 } 66