Java Code Examples for org.jboss.arquillian.test.spi.TestResult#getStatus()

The following examples show how to use org.jboss.arquillian.test.spi.TestResult#getStatus() . 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: DefaultAnnotationScreenshootingStrategy.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        Screenshot screenshotAnnotation = ScreenshotAnnotationScanner.getScreenshotAnnotation(((AfterTestLifecycleEvent) event).getTestMethod());

        if (screenshotAnnotation != null) {
            if (screenshotAnnotation.takeAfterTest()) {
                return true;
            }
            if (result.getStatus() == Status.FAILED && screenshotAnnotation.takeWhenTestFailed()) {
                return true;
            }
        }
    }

    return false;
}
 
Example 2
Source File: VideoTaker.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
public void onStopRecording(@Observes StopRecordVideo event) throws IOException {
    Video video = recorder.get().stopRecording();

    TestResult testResult = event.getVideoMetaData().getTestResult();

    if (testResult != null) {
        Status status = testResult.getStatus();
        appendStatus(video, status);

        resourceRegister.get().addReported(video);

        if ((status.equals(Status.PASSED) && !configuration.get().getTakeOnlyOnFail())
            || (status.equals(Status.FAILED) && configuration.get().getTakeOnlyOnFail())) {
            propertyReportEvent.fire(new PropertyReportEvent(getVideoEntry(video)));
        }
    } else {
        resourceRegister.get().addTaken(video);
    }
}
 
Example 3
Source File: DefaultScreenshootingStrategy.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        if (configuration.getTakeAfterTest()) {
            return true;
        }
        if (result.getStatus() == Status.FAILED && configuration.getTakeWhenTestFailed()) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: ScreenshooterLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
public void afterTest(@Observes(precedence = 50) AfterTestLifecycleEvent event, TestResult result) {
    if (new TakingScreenshotDecider(recorderStrategyRegister.get()).decide(event, result)) {
        ScreenshotMetaData metaData = getMetaData(event);
        metaData.setTestResult(result);
        metaData.setResourceType(getScreenshotType());

        When when = result.getStatus() == TestResult.Status.FAILED ? When.FAILED : When.AFTER;

        DefaultFileNameBuilder nameBuilder = new DefaultFileNameBuilder();
        String screenshotName = nameBuilder
            .withMetaData(metaData)
            .withStage(when)
            .build();

        beforeScreenshotTaken.fire(new BeforeScreenshotTaken(metaData));

        TakeScreenshot takeScreenshooter = new TakeScreenshot(screenshotName, metaData, when, null);
        takeScreenshot.fire(takeScreenshooter);

        metaData.setBlurLevel(resolveBlurLevel(event));
        org.arquillian.extension.recorder.screenshooter.Screenshot screenshot = takeScreenshooter.getScreenshot();
        if(screenshot != null) {
            metaData.setFilename(screenshot.getResource());
        }

        afterScreenshotTaken.fire(new AfterScreenshotTaken(metaData));
    }
}
 
Example 5
Source File: DefaultVideoStrategy.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        switch (result.getStatus()) {
            case FAILED:
                return configuration.getTakeOnlyOnFail();
            case PASSED:
                return configuration.getStartBeforeTest() || configuration.getTakeOnlyOnFail();
            case SKIPPED:
            default:
                return false;
        }
    }
    return false;
}
 
Example 6
Source File: ReporterLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
public void observeAfterTest(@Observes(precedence = Integer.MIN_VALUE) AfterTestLifecycleEvent event, TestResult result) {

        int count = lifecycleCountRegister.get(event.getTestMethod());

        lifecycleCountRegister.put(event.getTestMethod(), --count);

        if (lifecycleCountRegister.get(event.getTestMethod()) == 0) {
            TestMethodReport testMethodReport = reporter.get().getLastTestMethodReport();

            testMethodReport.setStatus(result.getStatus());
            testMethodReport.setDuration(result.getEnd() - result.getStart());
            testMethodReport.setReportMessage(ReportMessageParser.parseTestReportMessage(event.getTestMethod()));

            if (result.getStatus() == Status.FAILED && result.getThrowable() != null) {
                testMethodReport.setException(getStackTrace(result.getThrowable()));
            }

            inTestResourceReportEvent.fire(new InTestResourceReport());

            reporter.get().setReporterCursor(new ReporterCursor(reporter.get().getLastTestClassReport()));

            report(event, descriptor.get());

            lifecycleCountRegister.remove(event.getTestMethod());
        }
    }