use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestVideoUtils method testReadAviLastStep.
/**
* Check no picture is extracted for "Test end" step
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadAviLastStep() throws IOException {
LocalDateTime videoStartDateTime = LocalDateTime.parse("2021-11-15T13:15:30");
TestStepManager.getInstance().setVideoStartDate(Date.from(videoStartDateTime.toInstant(ZoneOffset.UTC)));
TestStep step = new TestStep(TestStepManager.LAST_STEP_NAME, null, new ArrayList<String>(), false);
step.setStartDate(Date.from(videoStartDateTime.plusSeconds(1).toInstant(ZoneOffset.UTC)));
step.setVideoTimeStamp(1000);
Assert.assertEquals(step.getSnapshots().size(), 0);
VideoUtils.extractReferenceForSteps(createVideoFileFromResource("tu/video/videoCapture.avi"), Arrays.asList(step), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
Assert.assertEquals(step.getSnapshots().size(), 0);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestVideoUtils method testReadAviSeveralStepsWithSameTimeStamp.
/**
* Check the case where several steps have the same timestamp. In this case, only the last step gets a picture
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadAviSeveralStepsWithSameTimeStamp() throws IOException {
LocalDateTime videoStartDateTime = LocalDateTime.parse("2021-11-15T13:15:30");
TestStepManager.getInstance().setVideoStartDate(Date.from(videoStartDateTime.toInstant(ZoneOffset.UTC)));
TestStep step = new TestStep("step 1", null, new ArrayList<String>(), false);
step.setStartDate(Date.from(videoStartDateTime.plusSeconds(1).toInstant(ZoneOffset.UTC)));
step.setVideoTimeStamp(1000);
TestStep step2 = new TestStep("step 1", null, new ArrayList<String>(), false);
step2.setStartDate(Date.from(videoStartDateTime.plusSeconds(1).toInstant(ZoneOffset.UTC)));
step2.setVideoTimeStamp(1000);
Assert.assertEquals(step.getSnapshots().size(), 0);
Assert.assertEquals(step2.getSnapshots().size(), 0);
VideoUtils.extractReferenceForSteps(createVideoFileFromResource("tu/video/videoCapture.avi"), Arrays.asList(step, step2), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
Assert.assertEquals(step.getSnapshots().size(), 0);
Assert.assertEquals(step2.getSnapshots().size(), 1);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestVideoUtils method testReadAviTimestampOutsideVideo.
/**
* Check no error is raised and no picture is extracted if timestamp is out of video
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadAviTimestampOutsideVideo() throws IOException {
LocalDateTime videoStartDateTime = LocalDateTime.parse("2021-11-15T13:15:30");
TestStepManager.getInstance().setVideoStartDate(Date.from(videoStartDateTime.toInstant(ZoneOffset.UTC)));
TestStep step = new TestStep("step 1", null, new ArrayList<String>(), false);
step.setStartDate(Date.from(videoStartDateTime.plusSeconds(100).toInstant(ZoneOffset.UTC)));
step.setVideoTimeStamp(100000);
Assert.assertEquals(step.getSnapshots().size(), 0);
VideoUtils.extractReferenceForSteps(createVideoFileFromResource("tu/video/videoCapture.avi"), Arrays.asList(step), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
Assert.assertEquals(step.getSnapshots().size(), 0);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class JiraConnector method formatFailedStep.
/**
* @param failedSteps
* @param fullDescription
*/
private void formatFailedStep(List<TestStep> failedSteps, StringBuilder fullDescription) {
if (!failedSteps.isEmpty()) {
fullDescription.append("h2. Steps in error\n");
for (TestStep failedStep : failedSteps) {
fullDescription.append(String.format("* *" + STEP_KO_PATTERN + "%s*\n", failedStep.getPosition(), failedStep.getName().trim()));
if (failedStep.getRootCause() != null) {
fullDescription.append(String.format("+Possible cause:+ %s%s\n", failedStep.getRootCause(), failedStep.getRootCauseDetails() == null || failedStep.getRootCauseDetails().trim().isEmpty() ? "" : " => " + failedStep.getRootCauseDetails()));
}
fullDescription.append(String.format("{code:java}%s{code}\n\n", failedStep.toString()));
}
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class JiraConnector method updateIssue.
@Override
public void updateIssue(String issueId, String messageUpdate, List<ScreenShot> screenShots, TestStep lastFailedStep) {
IssueRestClient issueClient = restClient.getIssueClient();
Issue issue;
try {
issue = issueClient.getIssue(issueId).claim();
} catch (RestClientException e) {
throw new ScenarioException(String.format("Jira issue %s does not exist, cannot update it", issueId));
}
try {
if (!screenShots.isEmpty()) {
issueClient.addAttachments(issue.getAttachmentsUri(), screenShots.stream().peek(s -> logger.info("file ->" + s.getFullImagePath())).map(s -> new File(s.getFullImagePath())).collect(Collectors.toList()).toArray(new File[] {}));
}
// add comment
issueClient.addComment(issue.getCommentsUri(), Comment.valueOf(formatUpdateDescription(messageUpdate, screenShots, lastFailedStep).toString()));
logger.info(String.format("Jira %s updated", issueId));
} catch (Exception e) {
logger.error(String.format("Jira %s not modified: %s", issueId, e.getMessage()));
throw e;
}
}
Aggregations