问题描述
我正在尝试使用ANT运行基于数据提供者的测试。我的主要班级指向testNG文件
XmlSuite suite=new XmlSuite();
suite.setName("Test Results");
suite.setPreserveOrder(true);
List<XmlSuite> suits=new ArrayList<XmlSuite>();
suits.add(suite);
List<XmlPackage> xpackage=new ArrayList<XmlPackage>();
xpackage.add(new XmlPackage(TestProperties.TESTNG_PACKAGE.toString()));
XmlTest test=new XmlTest(suite);
test.setPackages(xpackage);
String groups=TestProperties.TESTNG_GROUP.toString();
System.out.println("groups are:"+groups);
String groupArray[]=groups.split(",");
List<String> includedGroups=new ArrayList<String>();
includedGroups.addAll(Arrays.asList(groupArray));
test.setIncludedGroups(includedGroups);
TestNG tng=new TestNG();
tng.setOutputDirectory("test-output");
tng.setXmlSuites(suits);
tng.run();
System.exit(0);
现在,在我的Testcase文件中,
@BeforeClass(alwaysRun = true)
public void pretest() throws IOException,GeneralSecurityException {
Pretest
}
@Test(groups= {"indicatorGroup","",""},description = "Validate indicator uploaded",dataProvider = "getIndicatorData")
public void indicatorUpload(String txt){
test
}
@DataProvider
public Object[] getIndicatorData() throws IOException,GeneralSecurityException
{
bla bla
for(int i=0; i<contents.length; i++) {
System.out.println(contents[i]);
if(!contents[i].contains("README")) {
blah blah
System.out.println(path);
names.add(path);
}
}
String[] myArray = new String[names.size()];
names.toArray(myArray);
return myArray;
}
@AfterClass(alwaysRun = true)
public void afterMethod() throws IOException {
System.out.println("Deleting all files after operation.....");
}
问题是,如果我从Testng运行,它们会毫无问题地运行。即,如果我右键单击该文件,单击“运行”,然后单击“以Testng Test身份运行”。 但是,如果我从构建文件运行,则在第一次迭代之后,我在上课之前启动的驱动程序将关闭,而其余测试将失败。这导致我的测试在詹金斯考试中失败。 有人可以帮我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)