final String suiteName = firstNonNull(testSuite.getTitle(), testSuite.getName(), "unknown test suite"); final String testClass = firstNonNull( findLabelValue(source.getLabels(), TEST_CLASS.value()), findLabelValue(testSuite.getLabels(), TEST_CLASS.value()), testSuite.getName(), ); final String testMethod = firstNonNull( findLabelValue(source.getLabels(), TEST_METHOD.value()), source.getName(), UNKNOWN ); final String name = firstNonNull(source.getTitle(), source.getName(), "unknown test case"); final Optional<ru.yandex.qatools.allure.model.Label> historyId = findLabel(source.getLabels(), "historyId"); if (historyId.isPresent()) { dest.setHistoryId(historyId.get().getValue()); final Status status = convert(source.getStatus()); dest.setStatus(status); dest.setTime(Time.create(source.getStart(), source.getStop())); dest.setParameters(parameters); dest.setDescription(getDescription(testSuite.getDescription(), source.getDescription())); dest.setDescriptionHtml(getDescriptionHtml(testSuite.getDescription(), source.getDescription())); Optional.ofNullable(source.getFailure()).ifPresent(failure -> { dest.setStatusMessage(failure.getMessage()); dest.setStatusTrace(failure.getStackTrace()); });
private List<ru.yandex.qatools.allure.model.Parameter> getEnvironmentParameters(final TestCaseResult testCase) { return testCase.getParameters().stream().filter(this::hasEnvType).collect(toList()); }
/** * Create an instance of {@link TestCaseResult } * */ public TestCaseResult createTestCaseResult() { return new TestCaseResult(); }
public void fire(TestCaseFinishedEvent event) { TestCaseResult testCase = testCaseStorage.get(); event.process(testCase); Step root = stepStorage.pollLast(); if (Status.PASSED.equals(testCase.getStatus())) { new RemoveAttachmentsEvent(AllureReportConfig.newInstance().getRemoveAttachments()).process(root); } testCase.getSteps().addAll(root.getSteps()); testCase.getAttachments().addAll(root.getAttachments()); stepStorage.remove(); testCaseStorage.remove(); }
/** * If test not finished yet (in our case if stop time is zero) mark it as interrupted. * Set message, stop time and status. */ public void markTestcaseAsInterruptedIfNotFinishedYet(TestCaseResult testCase) { if (testCase.getStop() == 0L) { testCase.setStop(System.currentTimeMillis()); testCase.setStatus(Status.BROKEN); testCase.setFailure(new Failure().withMessage("Test was interrupted")); } } }
/** * Create fake test case, which will used for mark suite as interrupted. */ public TestCaseResult createFakeTestcaseWithWarning(TestSuiteResult testSuite) { return new TestCaseResult() .withName(testSuite.getName()) .withTitle(testSuite.getName()) .withStart(testSuite.getStart()) .withStop(System.currentTimeMillis()) .withFailure(new Failure().withMessage("Test suite was interrupted, some test cases may be lost")) .withStatus(Status.BROKEN); }
List<TestCase> transform(List<TestSuiteResult> result) { List<TestCase> testCases = new ArrayList<TestCase>(); for (TestSuiteResult currentTestSuiteResult : result) { for (TestCaseResult currentTestCaseResult : currentTestSuiteResult.getTestCases()) { TestCase currentTestCase = new TestCase(); currentTestCase.setName(currentTestCaseResult.getName()); currentTestCase.setUniqueId(generateUniqueId(currentTestCaseResult)); currentTestCase.setStoryKeys(getStoryKeys(currentTestCaseResult)); currentTestCase.setKey(getJiraKey(currentTestCaseResult)); currentTestCase.setStatus(getStatus(currentTestCaseResult)); currentTestCase.setSeverity(getSeverity(currentTestCaseResult)); currentTestCase.setSteps(addTestSteps(currentTestCaseResult.getSteps(), 1)); testCases.add(currentTestCase); } } return testCases; }
public TestCaseResult withLabels(Collection<Label> values) { if (values!= null) { getLabels().addAll(values); } return this; }
public TestCaseResult withSteps(Step... values) { if (values!= null) { for (Step value: values) { getSteps().add(value); } } return this; }
private TestStatus getStatus(TestCaseResult testCaseResult) { switch (testCaseResult.getStatus()) { case FAILED: return TestStatus.FAILED; case BROKEN: return TestStatus.FAILED; case PASSED: return TestStatus.PASSED; default: return TestStatus.NOT_EXECUTED; } }
public TestCaseResult withAttachments(Attachment... values) { if (values!= null) { for (Attachment value: values) { getAttachments().add(value); } } return this; }
private String generateUniqueId(TestCaseResult testCaseResult) { return testCaseResult.getName(); }
/** * Process TestCaseFinishedEvent. Add steps and attachments from * top step from stepStorage to current testCase, then remove testCase * and step from stores. Also remove attachments matches removeAttachments * config. * * @param event to process */ public void fire(TestCaseFinishedEvent event) { TestCaseResult testCase = testCaseStorage.get(); event.process(testCase); Step root = stepStorage.pollLast(); if (Status.PASSED.equals(testCase.getStatus())) { new RemoveAttachmentsEvent(AllureConfig.newInstance().getRemoveAttachments()).process(root); } testCase.getSteps().addAll(root.getSteps()); testCase.getAttachments().addAll(root.getAttachments()); stepStorage.remove(); testCaseStorage.remove(); notifier.fire(event); }
public TestCaseResult withLabels(Label... values) { if (values!= null) { for (Label value: values) { getLabels().add(value); } } return this; }
public TestCaseResult withSteps(Collection<Step> values) { if (values!= null) { getSteps().addAll(values); } return this; }
public TestCaseResult withAttachments(Collection<Attachment> values) { if (values!= null) { getAttachments().addAll(values); } return this; }
lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName)) { return false; lhsTitle = this.getTitle(); String rhsTitle; rhsTitle = that.getTitle(); if (!strategy.equals(LocatorUtils.property(thisLocator, "title", lhsTitle), LocatorUtils.property(thatLocator, "title", rhsTitle), lhsTitle, rhsTitle)) { return false; lhsDescription = this.getDescription(); Description rhsDescription; rhsDescription = that.getDescription(); if (!strategy.equals(LocatorUtils.property(thisLocator, "description", lhsDescription), LocatorUtils.property(thatLocator, "description", rhsDescription), lhsDescription, rhsDescription)) { return false; lhsFailure = this.getFailure(); Failure rhsFailure; rhsFailure = that.getFailure(); if (!strategy.equals(LocatorUtils.property(thisLocator, "failure", lhsFailure), LocatorUtils.property(thatLocator, "failure", rhsFailure), lhsFailure, rhsFailure)) { return false; lhsSteps = this.getSteps(); List<Step> rhsSteps; rhsSteps = that.getSteps(); if (!strategy.equals(LocatorUtils.property(thisLocator, "steps", lhsSteps), LocatorUtils.property(thatLocator, "steps", rhsSteps), lhsSteps, rhsSteps)) { return false;
private List<Parameter> getParameters(final TestCaseResult source) { final TreeSet<Parameter> parametersSet = new TreeSet<>( comparing(Parameter::getName, nullsFirst(naturalOrder())) .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())) ); parametersSet.addAll(convert(source.getParameters(), this::hasArgumentType, this::convert)); return new ArrayList<>(parametersSet); }
private List<String> getStoryKeys(TestCaseResult currentTestCaseResult) { List<String> storyKeys = new ArrayList<String>(); for (Label currentLabel : currentTestCaseResult.getLabels()) { if (currentLabel.getName().equalsIgnoreCase("story") && !currentLabel.getValue().isEmpty()) { storyKeys.add(currentLabel.getValue()); } } return storyKeys.size() != 0 ? storyKeys : null; }
@Override protected TestCaseResult initialValue() { return new TestCaseResult(); } }