1 package test.parameters; 2 3 import org.testng.TestListenerAdapter; 4 import org.testng.TestNG; 5 import org.testng.annotations.Test; 6 import org.testng.xml.XmlClass; 7 import org.testng.xml.XmlInclude; 8 import org.testng.xml.XmlSuite; 9 import org.testng.xml.XmlTest; 10 11 import test.SimpleBaseTest; 12 13 import java.util.Arrays; 14 15 public class ShadowTest extends SimpleBaseTest { 16 17 @Test parametersShouldNotBeShadowed()18 public void parametersShouldNotBeShadowed() { 19 XmlSuite s = createXmlSuite("s"); 20 XmlTest t = createXmlTest(s, "t"); 21 22 { 23 XmlClass c1 = new XmlClass(Shadow1SampleTest.class.getName()); 24 XmlInclude include1 = new XmlInclude("test1"); 25 include1.setXmlClass(c1); 26 c1.getLocalParameters().put("a", "First"); 27 c1.getIncludedMethods().add(include1); 28 t.getXmlClasses().add(c1); 29 } 30 31 { 32 XmlClass c2 = new XmlClass(Shadow2SampleTest.class.getName()); 33 XmlInclude include2 = new XmlInclude("test2"); 34 include2.setXmlClass(c2); 35 c2.getLocalParameters().put("a", "Second"); 36 c2.getIncludedMethods().add(include2); 37 t.getXmlClasses().add(c2); 38 } 39 40 TestNG tng = create(); 41 tng.setXmlSuites(Arrays.asList(s)); 42 TestListenerAdapter tla = new TestListenerAdapter(); 43 tng.addListener(tla); 44 tng.run(); 45 46 // System.out.println(s.toXml()); 47 assertTestResultsEqual(tla.getPassedTests(), Arrays.asList("test1", "test2")); 48 } 49 } 50