TestNG无法设置progammatic默认测试名称

时间:2013-04-08 10:26:10

标签: java testng

我正在尝试使用以下代码更改默认测试名称,但仍然保留为:默认测试名称而不是测试我将其设置为:

    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();

1 个答案:

答案 0 :(得分:0)

好的,基本上添加了对方法的调用: testng.setDefaultTestName(“您的默认测试名称”);

我还需要实现界面: IMethodInterceptor