我有一个测试(我使用java selenium testng开发),其中包含几个测试用例,我希望能够将它们重复'X'次。
我编写的测试如果不重复就启动此测试,它将满足我想要达到的目标。
@Test(priority = 110, dataProvider = "backupDetailsProvider")
public void addBackupByDevice(String... devices) throws ApiException {
BackupRow backupRow = backupPage.addNewBackupByDevices(devices);
backupNameDevice = backupRow.backupNameTxt;
Assert.assertNotNull(backupRow, "failed to add backup=[first] to server");
info("user=[%s] added successfully" , backupRow);
addToBackupMap(backupNameDevice);
}
@DataProvider(name = "backupFileProvider")
public Object[][] backupFileProvider(){
return initSingleParamProvider(backupFileResponseNonLabled);
}
@DataProvider(name = "backupDetailsProvider")
public Object[][] backupDetailsProvider() {
return new Object[][]{
{new String[]{nonLabelDevice.vendor + "-" + nonLabelDevice.ip}}
};
}
@Test(priority = 130, dataProvider = "backupScheduleProvider", groups = {BACKUP_COMPLETE})
public void verifyInLogBackupJobStarted(ScheduleRequest schedule) throws Exception {
servicesLog.waitAndVerifyBackupJobStarted(schedule);
}
@DataProvider(name = "backupScheduleProvider")
public Object[][] backupScheduleProvider() {
return initParamArrayProvider(backupMap.values().toArray());
}
@Test(priority = 140, dataProvider = "devicesInfoProvider", groups = {BACKUP_COMPLETE})
public void verifyInLogBackupJobCompleted(DeviceInfo deviceInfo) throws Exception {
info("Device id is: " + deviceInfo.getId());
servicesLog.waitAndVerifyBackupJobCompleted(deviceInfo.getId());
}
我希望能够按照相同的顺序执行这些动作,但是正如我在重复执行4次之前所说的那样,我没有找到任何解决办法来解决它。
答案 0 :(得分:0)
使用循环,根据需要,分别用于每个测试或用于所有测试。
答案 1 :(得分:0)
有invocationCount
annotation定义了将执行特定测试用例的次数:
鉴于您具有以下结构:
@Test(invocationCount = 10)
public void someTestMethod() {
}
someTestMethod
将运行10次:
参考文献: