use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testTestStepWithrootCause.
@Test(groups = { "ut" })
public void testTestStepWithrootCause() {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true, RootCause.REGRESSION, "details", false);
// mandatory so that errorCauseDetails is not null
step.setFailed(true);
Assert.assertEquals(step.getRootCause(), RootCause.REGRESSION);
Assert.assertEquals(step.getRootCauseDetails(), "details");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class Uft method addStepWithoutXml.
private void addStepWithoutXml(List<TestStep> listStep, String messageException, Exception e) {
logger.error(messageException + e.getMessage());
TestStep readStep = new TestStep("UFT: " + scriptName, Reporter.getCurrentTestResult(), new ArrayList<>(), false);
readStep.addMessage(new TestMessage(messageException + e.getMessage(), MessageType.ERROR));
listStep.add(readStep);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class Uft method readStep.
/**
* Read a step element
* <p>
* // * @param parentStep
*
* @param stepElement
*/
private TestAction readStep(Element stepElement) {
TestAction stepAction;
List<Element> stepList = stepElement.getChildren("Step");
org.jsoup.nodes.Document htmlDoc = Jsoup.parseBodyFragment(stepElement.getChildText("Details"));
String details = htmlDoc.text();
String stepDescription = String.format("%s: %s", stepElement.getChildText("Obj"), details).trim();
if (stepList.isEmpty()) {
stepAction = new TestAction(stepDescription, false, new ArrayList<>());
} else {
stepAction = new TestStep(stepDescription, Reporter.getCurrentTestResult(), new ArrayList<>(), false);
for (Element subStepElement : stepElement.getChildren("Step")) {
TestAction readAction = readStep(subStepElement);
((TestStep) stepAction).addAction(readAction);
}
}
return stepAction;
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class BugTracker method createIssueBean.
/**
* Create an issue object
* @param testName method name (name of scenario)
* @param description Description of the test. May be null
* @param testSteps Test steps of the scenario
* @param issueOptions options for the new issue
* @return
*/
public IssueBean createIssueBean(String summary, String testName, String description, List<TestStep> testSteps, Map<String, String> issueOptions) {
TestStep lastTestStep = null;
List<TestStep> failedSteps = new ArrayList<>();
for (TestStep testStep : testSteps) {
// "Test end" step should never be considered as failed, because it reflects the overall test result
if (Boolean.TRUE.equals(testStep.getFailed()) && !testStep.isTestEndStep() && // if the step has the flag disabling bugtracker, do not count it as failed step
!testStep.isDisableBugtracker()) {
failedSteps.add(testStep);
}
if (testStep.isTestEndStep()) {
lastTestStep = testStep;
break;
}
}
// don't create issue if no failed step is present
if (failedSteps.isEmpty()) {
logger.info("No failed steps. It may be due to a failed step marked as disabled for bugtracker");
return null;
}
// don't create issue if test has not been executed or not completed
if (lastTestStep == null) {
return null;
}
List<ScreenShot> screenShots = lastTestStep.getSnapshots().stream().map(Snapshot::getScreenshot).collect(Collectors.toList());
StringBuilder fullDescription = new StringBuilder();
formatDescription(testName, failedSteps, lastTestStep, description, fullDescription);
File zipFile = null;
// provide detailedResult.zip file only when 'startedBy' is not present. This prevent from sending big reports to bugtracker
if (SeleniumTestsContextManager.getThreadContext().getStartedBy() == null) {
fullDescription.append("\n\nFor more details, see attached .zip file");
zipFile = createDetailedResultReport(testName);
}
String assignee = issueOptions.get("assignee");
String reporter = issueOptions.get("reporter");
return createIssueBean(summary, fullDescription.toString(), testName, // take the last failed step as step we will show as failed even if there are several
failedSteps.isEmpty() ? lastTestStep : failedSteps.get(failedSteps.size() - 1), assignee, reporter, screenShots, zipFile, issueOptions);
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class BugTracker method formatDescription.
/**
* Format description
* For any bugtracker, description is quite simple but it can be improved depending on bug tracker
* /!\ any method overriding this one MUST provide "STEP_KO_PATTERN" in the description because it's used to know if the failed step is the same
*
* @param testSteps
* @param fullDescription
* @param screenShots
* @return
*/
protected void formatDescription(String testName, List<TestStep> failedSteps, TestStep lastTestStep, String description, StringBuilder fullDescription) {
fullDescription.append(String.format("Test: %s\n", testName));
if (description != null) {
fullDescription.append(String.format("Description: %s\n", description));
}
if (SeleniumTestsContextManager.getThreadContext().getStartedBy() != null) {
fullDescription.append(String.format("Started by: %s\n", SeleniumTestsContextManager.getThreadContext().getStartedBy()));
}
for (TestStep failedStep : failedSteps) {
fullDescription.append(String.format("Error step %d (%s): %s\n", failedStep.getPosition(), failedStep.getName(), failedStep.getActionException()));
}
fullDescription.append("\n");
if (!failedSteps.isEmpty()) {
fullDescription.append("Steps in error\n");
for (TestStep failedStep : failedSteps) {
fullDescription.append(String.format(STEP_KO_PATTERN + "%s\n", failedStep.getPosition(), failedStep.getName()));
fullDescription.append("------------------------------------\n");
fullDescription.append(failedStep.toString() + "\n\n");
}
}
fullDescription.append("Last logs\n");
fullDescription.append(lastTestStep.toString());
}
Aggregations