ru.yandex.qatools.allure.model.Status Java Examples

The following examples show how to use ru.yandex.qatools.allure.model.Status. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllureTestListenerConfigMethodsTest.java    From allure1 with Apache License 2.0 6 votes vote down vote up
private void validateTestSuiteResult(TestSuiteResult testSuiteResult) {
    String brokenMethod = testSuiteResult.getName().replace(SUITE_PREFIX, "config");
    for (TestCaseResult result : testSuiteResult.getTestCases()) {
        String methodName = result.getName();
        Status status = result.getStatus();
        Status expectedStatus = Status.CANCELED;
        if (brokenMethod.startsWith(methodName)) {
            expectedStatus = Status.BROKEN;
        }
        if (brokenMethod.contains("After") && methodName.equalsIgnoreCase("test")) {
            expectedStatus = Status.PASSED;
        }
        assertThat(String.format("Wrong status for test <%s>, method <%s>", brokenMethod, methodName),
                status, equalTo(expectedStatus));
    }
}
 
Example #2
Source File: Allure.java    From allure1 with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: AllureReportGenerator.java    From AuTe-Framework with Apache License 2.0 5 votes vote down vote up
private List<Step> buildStepsForCyclicRequest(
        File resultDirectory,
        Status status,
        List<RequestData> requestDataList
) {
    List<Step> steps = new ArrayList<>();
    for (int i = 0; i < requestDataList.size(); i++) {
        RequestData requestData = requestDataList.get(i);
        steps.add(new Step()
                .withName("Request " + (i + 1))
                .withStatus(status)
                .withAttachments(requestDataAttachBuilder.build(resultDirectory, requestData)));
    }
    return steps;
}
 
Example #4
Source File: StatusDeserializer.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public Status deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    final String value = p.readValueAs(String.class);
    return Stream.of(Status.values())
            .filter(status -> status.value().equalsIgnoreCase(value))
            .findAny()
            .orElse(null);
}
 
Example #5
Source File: AllureShutdownHook.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: AllureShutdownHook.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * 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"));
    }
}
 
Example #7
Source File: AllureTestListenerMultipleSuitesTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Test
public void validatePendingTest() throws IOException {
    TestSuiteResult testSuite = AllureFileUtils.unmarshalSuites(resultsDir.toFile()).get(0);
    TestCaseResult testResult = testSuite.getTestCases().get(0);

    assertThat(testResult.getStatus(), equalTo(Status.PENDING));  
    assertThat(testResult.getDescription().getValue(), equalTo("This is pending test"));
}
 
Example #8
Source File: TestCaseStartedEvent.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * Sets to testCase start time, default status, name, title, description and labels
 *
 * @param testCase to change
 */
@Override
public void process(TestCaseResult testCase) {
    testCase.setStart(System.currentTimeMillis());
    testCase.setStatus(Status.PASSED);
    testCase.setName(getName());
    testCase.setTitle(getTitle());
    testCase.setDescription(getDescription());
    testCase.setLabels(getLabels());
}
 
Example #9
Source File: StepEventTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Test
public void testStepStartedEvent() throws Exception {
    new StepStartedEvent("name").withTitle("title").process(step);
    verify(step).setName("name");
    verify(step).setStart(anyLong());
    verify(step).setStatus(Status.PASSED);
    verify(step).setTitle("title");
    verifyNoMoreInteractions(step);
}
 
Example #10
Source File: StepStartedEvent.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * Sets name, status, start time and title to specified step
 *
 * @param step which will be changed
 */
@Override
public void process(Step step) {
    step.setName(getName());
    step.setStatus(Status.PASSED);
    step.setStart(System.currentTimeMillis());
    step.setTitle(getTitle());
}
 
Example #11
Source File: StepStorage.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * Construct new root step. Used for inspect problems with Allure lifecycle
 *
 * @return new root step marked as broken
 */
public Step createRootStep() {
    return new Step()
            .withName("Root step")
            .withTitle("Allure step processing error: if you see this step something went wrong.")
            .withStart(System.currentTimeMillis())
            .withStatus(Status.BROKEN);
}
 
Example #12
Source File: StatusDeserializer.java    From allure2 with Apache License 2.0 4 votes vote down vote up
protected StatusDeserializer() {
    super(io.qameta.allure.model.Status.class);
}
 
Example #13
Source File: StepEventTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Test
public void testStepCanceledEvent() throws Exception {
    new StepCanceledEvent().process(step);
    verify(step).setStatus(Status.CANCELED);
    verifyNoMoreInteractions(step);
}
 
Example #14
Source File: StepEventTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Test
public void testStepFailureEventBroken() throws Exception {
    new StepFailureEvent().withThrowable(new Exception()).process(step);
    verify(step).setStatus(Status.BROKEN);
    verifyNoMoreInteractions(step);
}
 
Example #15
Source File: StepEventTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@Test
public void testStepFailureEventFailed() throws Exception {
    new StepFailureEvent().withThrowable(new AssertionError()).process(step);
    verify(step).setStatus(Status.FAILED);
    verifyNoMoreInteractions(step);
}
 
Example #16
Source File: TestCaseCanceledEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the status {@link ru.yandex.qatools.allure.model.Status#CANCELED}
 *
 * @return the status {@link ru.yandex.qatools.allure.model.Status#CANCELED}
 */
@Override
protected Status getStatus() {
    return Status.CANCELED;
}
 
Example #17
Source File: TestCaseFailureEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns default message (using in {@link ru.yandex.qatools.allure.events.TestCaseStatusChangeEvent}
 * if throwable not specified)
 *
 * @return default message
 */
@Override
protected String getMessage() {
    return getStatus() == Status.FAILED ? "Test failed with unknown reason" : "Test broken with unknown reason";
}
 
Example #18
Source File: TestCaseFailureEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the status {@link ru.yandex.qatools.allure.model.Status#FAILED} if
 * throwable instance of {@link AssertionError} or
 * {@link ru.yandex.qatools.allure.model.Status#BROKEN} otherwise
 *
 * @return the status
 */
@Override
protected Status getStatus() {
    return throwable instanceof AssertionError ? Status.FAILED : Status.BROKEN;
}
 
Example #19
Source File: StepFailureEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Change step status to {@link ru.yandex.qatools.allure.model.Status#FAILED} if
 * throwable instance of AssertionError and to {@link ru.yandex.qatools.allure.model.Status#BROKEN}
 * otherwise
 *
 * @param step which will be changed
 */
@Override
public void process(Step step) {
    Status status = throwable instanceof AssertionError ? Status.FAILED : Status.BROKEN;
    step.setStatus(status);
}
 
Example #20
Source File: TestCaseStatusChangeEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the status, used in {@link #process(TestCaseResult)}
 * to change TestCaseResult status
 *
 * @return the status
 */
protected abstract Status getStatus();
 
Example #21
Source File: StepCanceledEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Change specified step status to {@link ru.yandex.qatools.allure.model.Status#CANCELED}
 *
 * @param step which will be changed
 */
@Override
public void process(Step step) {
    step.setStatus(Status.CANCELED);
}
 
Example #22
Source File: TestCasePendingEvent.java    From allure1 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the status {@link ru.yandex.qatools.allure.model.Status#PENDING}
 *
 * @return the status
 */
@Override
protected Status getStatus() {
    return Status.PENDING;
}