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;
}
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);
}
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);
}
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() + "\"");
}
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;
}
Aggregations