Search in sources :

Example 16 with TestCaseStep

use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.

the class TestCaseStepExampleBuilder method buildExample.

@Override
public TestCaseStep buildExample() {
    TestCaseStep step = new TestCaseStepBuilder(name).build();
    step.setStartDate(startDate);
    step.setStopDate(stopDate);
    step.setWarningTime(warningTime);
    step.setName(name);
    step.setState(state);
    step.addException(exception);
    step.setCreationDate(creationDate);
    return step;
}
Also used : TestCaseStep(org.sakuli.datamodel.TestCaseStep) TestCaseStepBuilder(org.sakuli.datamodel.builder.TestCaseStepBuilder)

Example 17 with TestCaseStep

use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.

the class TestCaseActionTest method testAddTestCaseStepWithAlreadyInitializedStep.

@Test
public void testAddTestCaseStepWithAlreadyInitializedStep() throws Throwable {
    when(loaderMock.getCurrentTestCase()).thenReturn(sample);
    sample.setWarningTime(0);
    sample.setCriticalTime(0);
    TestCaseStep predefinedStep = new TestCaseStep();
    predefinedStep.setId("step for JUnit");
    ArrayList<TestCaseStep> steps = new ArrayList<>();
    steps.add(predefinedStep);
    sample.setSteps(steps);
    TestCaseStep step = testSuiteMock.getTestCases().get(sample.getId()).getSteps().get(0);
    assertNotNull(step);
    assertEquals(step.getName(), "step_for_JUnit");
    step.refreshState();
    assertEquals(step.getState(), TestCaseStepState.INIT);
    long currentTime = new Date().getTime();
    testling.addTestCaseStep("step for JUnit", "" + (currentTime - 10000), "" + currentTime, //warning
    9);
    assertEquals(sample.getSteps().size(), 1);
    assertNotNull(step);
    assertEquals(step.getName(), "step_for_JUnit");
    assertEquals(step.getDuration(), 10.0f, "duration is not correct");
    assertEquals(step.getState(), TestCaseStepState.WARNING);
}
Also used : ArrayList(java.util.ArrayList) TestCaseStep(org.sakuli.datamodel.TestCaseStep) Date(java.util.Date) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 18 with TestCaseStep

use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.

the class TestCaseStepBuilderTest method testBuild.

@Test
public void testBuild() throws Exception {
    TestCaseStep step = new TestCaseStepBuilder("step for unit test").build();
    assertEquals(step.getId(), "step_for_unit_test");
    assertEquals(step.getName(), "step_for_unit_test");
    assertEquals(step.getState(), TestCaseStepState.INIT);
}
Also used : TestCaseStep(org.sakuli.datamodel.TestCaseStep) Test(org.testng.annotations.Test)

Example 19 with TestCaseStep

use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.

the class TestCaseAction method addTestCaseStep.

/**
     * Save a new step to a existing test case. Must be called before {@link #saveResult(String, String, String, String,
     * String)}
     *
     * @param stepName    name of this step
     * @param startTime   start time in milliseconds
     * @param stopTime    end time in milliseconds
     * @param warningTime warning threshold in seconds. If the threshold is set to 0, the execution time will never exceed, so the state will be always OK!
     * @throws SakuliException
     */
@LogToResult(message = "add a step to the current test case")
public void addTestCaseStep(String stepName, String startTime, String stopTime, int warningTime) throws SakuliException {
    if (stepName == null || stepName.isEmpty() || stepName.equals("undefined")) {
        handleException("Please set a Name - all values of the test case step need to be set!");
    }
    String errormsg = TestCaseStepHelper.checkWarningTime(warningTime, stepName);
    if (errormsg != null) {
        handleException(errormsg);
    }
    TestCaseStep step = findStep(stepName);
    try {
        step.setStartDate(new Date(Long.parseLong(startTime)));
        step.setStopDate(new Date(Long.parseLong(stopTime)));
        step.setWarningTime(warningTime);
    } catch (NullPointerException | NumberFormatException e) {
        loader.getExceptionHandler().handleException(e);
    }
    logger.debug("duration of the step \"" + stepName + "\": " + step.getDuration() + " sec.");
    step.refreshState();
    logger.debug("result of step \"" + stepName + "\": " + step.getState());
    loader.getCurrentTestCase().addStep(step);
    logger.debug("test case step \"" + step.getName() + "\" saved to test case \"" + loader.getCurrentTestCase().getId() + "\"");
}
Also used : TestCaseStep(org.sakuli.datamodel.TestCaseStep) Date(java.util.Date) LogToResult(org.sakuli.actions.logging.LogToResult)

Example 20 with TestCaseStep

use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.

the class TestCaseStepBuilder method build.

@Override
public TestCaseStep build() {
    TestCaseStep newTestCase = new TestCaseStep();
    newTestCase.setName(name);
    newTestCase.setState(stepState != null ? stepState : TestCaseStepState.INIT);
    newTestCase.setCreationDate(creationDate);
    return newTestCase;
}
Also used : TestCaseStep(org.sakuli.datamodel.TestCaseStep)

Aggregations

TestCaseStep (org.sakuli.datamodel.TestCaseStep)21 Test (org.testng.annotations.Test)10 BaseTest (org.sakuli.BaseTest)8 TestCase (org.sakuli.datamodel.TestCase)8 TestSuite (org.sakuli.datamodel.TestSuite)6 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 DaoTestCaseStep (org.sakuli.services.forwarder.database.dao.DaoTestCaseStep)3 IOException (java.io.IOException)2 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)2 DaoTestCase (org.sakuli.services.forwarder.database.dao.DaoTestCase)2 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 LogToResult (org.sakuli.actions.logging.LogToResult)1 SakuliForwarderException (org.sakuli.exceptions.SakuliForwarderException)1 DaoTestSuite (org.sakuli.services.forwarder.database.dao.DaoTestSuite)1 ScreenshotDiv (org.sakuli.services.forwarder.gearman.model.ScreenshotDiv)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 SimpleJdbcInsert (org.springframework.jdbc.core.simple.SimpleJdbcInsert)1