Search in sources :

Example 91 with TestStep

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 92 with TestStep

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 93 with TestStep

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 94 with TestStep

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()));
        }
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep)

Example 95 with TestStep

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;
    }
}
Also used : Arrays(java.util.Arrays) IssueRestClient(com.atlassian.jira.rest.client.api.IssueRestClient) CimFieldInfo(com.atlassian.jira.rest.client.api.domain.CimFieldInfo) Priority(com.atlassian.jira.rest.client.api.domain.Priority) Issue(com.atlassian.jira.rest.client.api.domain.Issue) URISyntaxException(java.net.URISyntaxException) IssueType(com.atlassian.jira.rest.client.api.domain.IssueType) HashMap(java.util.HashMap) Snapshot(com.seleniumtests.reporter.logger.Snapshot) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) SeleniumTestsContextManager(com.seleniumtests.core.SeleniumTestsContextManager) Logger(org.apache.log4j.Logger) BugTracker(com.seleniumtests.connectors.bugtracker.BugTracker) WaitHelper(com.seleniumtests.util.helper.WaitHelper) ImmutableList(com.google.common.collect.ImmutableList) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) Map(java.util.Map) IssueInput(com.atlassian.jira.rest.client.api.domain.input.IssueInput) Project(com.atlassian.jira.rest.client.api.domain.Project) URI(java.net.URI) ScenarioException(com.seleniumtests.customexception.ScenarioException) RestClientException(com.atlassian.jira.rest.client.api.RestClientException) Transition(com.atlassian.jira.rest.client.api.domain.Transition) BasicIssue(com.atlassian.jira.rest.client.api.domain.BasicIssue) JiraRestClient(com.atlassian.jira.rest.client.api.JiraRestClient) CustomFieldOption(com.atlassian.jira.rest.client.api.domain.CustomFieldOption) IssueInputBuilder(com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder) TransitionInput(com.atlassian.jira.rest.client.api.domain.input.TransitionInput) Field(com.atlassian.jira.rest.client.api.domain.Field) Collectors(java.util.stream.Collectors) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) File(java.io.File) SearchRestClient(com.atlassian.jira.rest.client.api.SearchRestClient) List(java.util.List) User(com.atlassian.jira.rest.client.api.domain.User) Version(com.atlassian.jira.rest.client.api.domain.Version) BasicProject(com.atlassian.jira.rest.client.api.domain.BasicProject) TestStep(com.seleniumtests.reporter.logger.TestStep) Entry(java.util.Map.Entry) Comment(com.atlassian.jira.rest.client.api.domain.Comment) BasicComponent(com.atlassian.jira.rest.client.api.domain.BasicComponent) AsynchronousJiraRestClientFactory(com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) BasicPriority(com.atlassian.jira.rest.client.api.domain.BasicPriority) Issue(com.atlassian.jira.rest.client.api.domain.Issue) BasicIssue(com.atlassian.jira.rest.client.api.domain.BasicIssue) RestClientException(com.atlassian.jira.rest.client.api.RestClientException) IssueRestClient(com.atlassian.jira.rest.client.api.IssueRestClient) File(java.io.File) ScenarioException(com.seleniumtests.customexception.ScenarioException) URISyntaxException(java.net.URISyntaxException) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) ScenarioException(com.seleniumtests.customexception.ScenarioException) RestClientException(com.atlassian.jira.rest.client.api.RestClientException)

Aggregations

TestStep (com.seleniumtests.reporter.logger.TestStep)190 Test (org.testng.annotations.Test)148 GenericTest (com.seleniumtests.GenericTest)120 ArrayList (java.util.ArrayList)80 TestAction (com.seleniumtests.reporter.logger.TestAction)47 File (java.io.File)37 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)25 Snapshot (com.seleniumtests.reporter.logger.Snapshot)24 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)19 TestMessage (com.seleniumtests.reporter.logger.TestMessage)16 GenericFile (com.seleniumtests.reporter.logger.GenericFile)15 MockitoTest (com.seleniumtests.MockitoTest)12 HashMap (java.util.HashMap)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 ITestResult (org.testng.ITestResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Uft (com.seleniumtests.connectors.extools.Uft)8 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)7 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)6