我正在尝试使用以下代码更改默认测试名称,但该值仍然保持为:默认测试名称而不是我将其设置为的测试:
TestNG testng = new TestNG();
XmlSuite suite = new XmlSuite();
suite.setName("Programmatic suite");
XmlTest xmlTest = new XmlTest(suite);
xmlTest.setName(testcase);
List<XmlClass> classes = new ArrayList<XmlClass>();
classes.add(new XmlClass(testsuite));
xmlTest.setXmlClasses(classes) ;
xmlTest.setName(testcase);
List<XmlTest> xmlTestsList = new ArrayList<XmlTest>();
xmlTestsList.add(xmlTest);
suite.setTests(xmlTestsList);
List<XmlSuite> suites = new ArrayList<XmlSuite>();
suites.add(suite);
testng.setXmlSuites(suites);
testng.setTestNames(Arrays.asList(testcase));
testng.setTestClasses(new Class[] { autotestClass });
testng.addListener(tla);
testng.run();