use of io.irontest.models.testrun.TestcaseIndividualRun in project irontest by zheng-wang.
the class DataDrivenTestcaseRunner method run.
@Override
public TestcaseRun run() throws JsonProcessingException {
DataDrivenTestcaseRun testcaseRun = new DataDrivenTestcaseRun();
Cloner cloner = new Cloner();
preProcessingForIIBTestcase();
startTestcaseRun(testcaseRun);
for (int dataTableRowIndex = 0; dataTableRowIndex < dataTable.getRows().size(); dataTableRowIndex++) {
LinkedHashMap<String, Object> dataTableRow = dataTable.getRows().get(dataTableRowIndex);
TestcaseIndividualRun individualRun = new TestcaseIndividualRun();
testcaseRun.getIndividualRuns().add(individualRun);
// start test case individual run
individualRun.setStartTime(new Date());
LOGGER.info("Start individually running test case with data table row: " + individualRun.getCaption());
individualRun.setResult(TestResult.PASSED);
getTestcaseRunContext().setTestcaseIndividualRunStartTime(individualRun.getStartTime());
if (isTestcaseHasWaitForProcessingCompletionAction()) {
// milliseconds
long secondFraction = individualRun.getStartTime().getTime() % 1000;
long millisecondsUntilNextSecond = 1000 - secondFraction;
Teststep waitStep = getTestcase().getTeststeps().get(0);
waitStep.setName("Wait " + millisecondsUntilNextSecond + " milliseconds");
waitStep.setOtherProperties(new WaitTeststepProperties(millisecondsUntilNextSecond));
}
getReferenceableStringProperties().put(IMPLICIT_PROPERTY_NAME_TEST_CASE_INDIVIDUAL_START_TIME, IMPLICIT_PROPERTY_DATE_TIME_FORMAT.format(individualRun.getStartTime()));
individualRun.setCaption((String) dataTableRow.get(DataTableColumn.COLUMN_NAME_CAPTION));
getReferenceableEndpointProperties().putAll(dataTable.getEndpointPropertiesInRow(dataTableRowIndex));
getReferenceableStringProperties().putAll(dataTable.getStringPropertiesInRow(dataTableRowIndex));
// run test steps
for (Teststep teststep : getTestcase().getTeststeps()) {
Teststep clonedTeststep = cloner.deepClone(teststep);
individualRun.getStepRuns().add(runTeststep(clonedTeststep));
}
// test case individual run ends
individualRun.setDuration(new Date().getTime() - individualRun.getStartTime().getTime());
LOGGER.info("Finish individually running test case with data table row: " + individualRun.getCaption());
for (TeststepRun teststepRun : individualRun.getStepRuns()) {
if (TestResult.FAILED == teststepRun.getResult()) {
individualRun.setResult(TestResult.FAILED);
break;
}
}
}
// test case run ends
testcaseRun.setDuration(new Date().getTime() - testcaseRun.getStartTime().getTime());
LOGGER.info("Finish running test case: " + getTestcase().getName());
for (TestcaseIndividualRun individualRun : testcaseRun.getIndividualRuns()) {
if (TestResult.FAILED == individualRun.getResult()) {
testcaseRun.setResult(TestResult.FAILED);
break;
}
}
// persist test case run details into database
getTestcaseRunDAO().insert(testcaseRun);
return testcaseRun;
}
Aggregations