Search in sources :

Example 1 with RegularTestcaseRun

use of io.irontest.models.testrun.RegularTestcaseRun in project irontest by zheng-wang.

the class RegularTestcaseRunner method run.

@Override
public TestcaseRun run() throws JsonProcessingException {
    RegularTestcaseRun testcaseRun = new RegularTestcaseRun();
    preProcessingForIIBTestcase();
    startTestcaseRun(testcaseRun);
    if (isTestcaseHasWaitForProcessingCompletionAction()) {
        // milliseconds
        long secondFraction = getTestcaseRunContext().getTestcaseRunStartTime().getTime() % 1000;
        long millisecondsUntilNextSecond = 1000 - secondFraction;
        Teststep waitStep = getTestcase().getTeststeps().get(0);
        waitStep.setName("Wait " + millisecondsUntilNextSecond + " milliseconds");
        waitStep.setOtherProperties(new WaitTeststepProperties(millisecondsUntilNextSecond));
    }
    // run test steps
    for (Teststep teststep : getTestcase().getTeststeps()) {
        testcaseRun.getStepRuns().add(runTeststep(teststep));
    }
    // test case run ends
    testcaseRun.setDuration(new Date().getTime() - testcaseRun.getStartTime().getTime());
    LOGGER.info("Finish running test case: " + getTestcase().getName());
    for (TeststepRun teststepRun : testcaseRun.getStepRuns()) {
        if (TestResult.FAILED == teststepRun.getResult()) {
            testcaseRun.setResult(TestResult.FAILED);
            break;
        }
    }
    // persist test case run details into database
    getTestcaseRunDAO().insert(testcaseRun);
    // prepare return object for UI (reduced contents for performance)
    List<TeststepRun> teststepRunsForUI = new ArrayList<>();
    for (TeststepRun stepRun : testcaseRun.getStepRuns()) {
        TeststepRun teststepRunForUI = new TeststepRun();
        teststepRunForUI.setId(stepRun.getId());
        teststepRunForUI.setResult(stepRun.getResult());
        Teststep teststepForUI = new Teststep();
        teststepForUI.setId(stepRun.getTeststep().getId());
        teststepRunForUI.setTeststep(teststepForUI);
        teststepRunsForUI.add(teststepRunForUI);
    }
    RegularTestcaseRun testcaseRunForUI = new RegularTestcaseRun();
    testcaseRunForUI.setId(testcaseRun.getId());
    testcaseRunForUI.setResult(testcaseRun.getResult());
    testcaseRunForUI.setStepRuns(teststepRunsForUI);
    return testcaseRunForUI;
}
Also used : Teststep(io.irontest.models.teststep.Teststep) WaitTeststepProperties(io.irontest.models.teststep.WaitTeststepProperties) TeststepRun(io.irontest.models.testrun.TeststepRun) ArrayList(java.util.ArrayList) RegularTestcaseRun(io.irontest.models.testrun.RegularTestcaseRun) Date(java.util.Date)

Example 2 with RegularTestcaseRun

use of io.irontest.models.testrun.RegularTestcaseRun in project irontest by zheng-wang.

the class TestcaseRunMapper method map.

public TestcaseRun map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
    TestcaseRun testcaseRun = new RegularTestcaseRun();
    testcaseRun.setId(rs.getLong("id"));
    testcaseRun.setTestcaseId(rs.getLong("testcase_id"));
    testcaseRun.setTestcaseName(rs.getString("testcase_name"));
    testcaseRun.setTestcaseFolderPath(rs.getString("testcase_folderpath"));
    testcaseRun.setStartTime(rs.getTimestamp("starttime"));
    testcaseRun.setDuration(rs.getLong("duration"));
    testcaseRun.setResult(TestResult.getByText(rs.getString("result")));
    return testcaseRun;
}
Also used : RegularTestcaseRun(io.irontest.models.testrun.RegularTestcaseRun) TestcaseRun(io.irontest.models.testrun.TestcaseRun) RegularTestcaseRun(io.irontest.models.testrun.RegularTestcaseRun)

Aggregations

RegularTestcaseRun (io.irontest.models.testrun.RegularTestcaseRun)2 TestcaseRun (io.irontest.models.testrun.TestcaseRun)1 TeststepRun (io.irontest.models.testrun.TeststepRun)1 Teststep (io.irontest.models.teststep.Teststep)1 WaitTeststepProperties (io.irontest.models.teststep.WaitTeststepProperties)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1