Search in sources :

Example 1 with TestStepFinished

use of cucumber.api.event.TestStepFinished in project page-factory-2 by sbtqa.

the class ErrorHandlerAspect method sendStepFinished.

@Around("sendStepFinished(event)")
public void sendStepFinished(ProceedingJoinPoint joinPoint, Event event) throws Throwable {
    TestStepFinished testStepFinished = (TestStepFinished) event;
    if (testStepFinished.result.getStatus() == Result.Type.FAILED && !Environment.isDriverEmpty() && !stepText.get().equals(Allure.getLifecycle().getCurrentTestCaseOrStep().toString())) {
        stepText.set(Allure.getLifecycle().getCurrentTestCaseOrStep().toString());
        ErrorHandler.attachError(testStepFinished.result.getError());
        ErrorHandler.attachScreenshot();
        if (PROPERTIES.isReportXmlAttachEnabled()) {
            try {
                ParamsHelper.addAttachmentToRender(Environment.getDriverService().getDriver().getPageSource().getBytes(), "Page source", Type.XML);
            } catch (InvalidElementStateException e) {
                LOG.error("Can't attach page source", e);
            }
        }
    }
    joinPoint.proceed();
}
Also used : TestStepFinished(cucumber.api.event.TestStepFinished) InvalidElementStateException(org.openqa.selenium.InvalidElementStateException) Around(org.aspectj.lang.annotation.Around)

Example 2 with TestStepFinished

use of cucumber.api.event.TestStepFinished in project page-factory-2 by sbtqa.

the class PrintParameters method beforeSendStepFinished.

@Before("sendStepFinished(event)")
public void beforeSendStepFinished(JoinPoint joinPoint, Event event) {
    TestStep testStep = ((TestStepFinished) event).testStep;
    if (testStep instanceof PickleStepTestStep) {
        this.testArguments.set(((PickleStepTestStep) testStep).getStepArgument());
        addAllureArguments();
    }
}
Also used : PickleStepTestStep(cucumber.api.PickleStepTestStep) TestStep(cucumber.api.TestStep) PickleStepTestStep(cucumber.api.PickleStepTestStep) TestStepFinished(cucumber.api.event.TestStepFinished) Before(org.aspectj.lang.annotation.Before)

Example 3 with TestStepFinished

use of cucumber.api.event.TestStepFinished in project page-factory-2 by sbtqa.

the class CriticalStepCheckAspect method sendStepFinished.

@Around("sendStepFinished(event)")
public void sendStepFinished(ProceedingJoinPoint joinPoint, TestStepFinished event) throws Throwable {
    PickleStep step = getDefinitionMatchStep(event.testStep);
    if (hasError(step)) {
        final Result result = new Result(Result.Type.AMBIGUOUS, event.result.getDuration(), ((PickleStepTag) step).getError());
        event = new TestStepFinished(event.getTimeStamp(), event.getTimeStampMillis(), event.getTestCase(), event.testStep, result);
    }
    joinPoint.proceed(new Object[] { event });
}
Also used : PickleStep(gherkin.pickles.PickleStep) TestStepFinished(cucumber.api.event.TestStepFinished) Result(cucumber.api.Result) TestResult(io.qameta.allure.model.TestResult) Around(org.aspectj.lang.annotation.Around)

Aggregations

TestStepFinished (cucumber.api.event.TestStepFinished)3 Around (org.aspectj.lang.annotation.Around)2 PickleStepTestStep (cucumber.api.PickleStepTestStep)1 Result (cucumber.api.Result)1 TestStep (cucumber.api.TestStep)1 PickleStep (gherkin.pickles.PickleStep)1 TestResult (io.qameta.allure.model.TestResult)1 Before (org.aspectj.lang.annotation.Before)1 InvalidElementStateException (org.openqa.selenium.InvalidElementStateException)1