Search in sources :

Example 1 with TestCase

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

the class CriticalStepCheckAspect method getCurrentTestCaseUid.

private String getCurrentTestCaseUid(TestCase testCase) throws IllegalAccessException {
    final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine();
    String uid = md5(testCaseLocation);
    AllureStorage allureStorage = (AllureStorage) readDeclaredField(Allure.getLifecycle(), "storage", true);
    Map<String, Object> storage = (Map<String, Object>) readDeclaredField(allureStorage, "storage", true);
    Collection<Object> testResults = storage.values();
    Optional<Object> testResultOptional = testResults.stream().filter(Objects::nonNull).filter(o -> o instanceof TestResult && ((TestResult) o).getHistoryId().equals(uid)).findFirst();
    return testResultOptional.isPresent() ? ((TestResult) testResultOptional.get()).getUuid() : uid;
}
Also used : Status(io.qameta.allure.model.Status) Arrays(java.util.Arrays) Result(cucumber.api.Result) Environment(ru.sbtqa.tag.pagefactory.environment.Environment) AllureNonCriticalError(ru.sbtqa.tag.pagefactory.exceptions.AllureNonCriticalError) TestStepFinished(cucumber.api.event.TestStepFinished) AutotestError(ru.sbtqa.tag.qautils.errors.AutotestError) Aspect(org.aspectj.lang.annotation.Aspect) Map(java.util.Map) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) Category(ru.sbtqa.tag.pagefactory.allure.Category) TestCase(cucumber.api.TestCase) TestResult(io.qameta.allure.model.TestResult) Collection(java.util.Collection) ResultsUtils.md5(io.qameta.allure.util.ResultsUtils.md5) Pointcut(org.aspectj.lang.annotation.Pointcut) StepDefinitionMatch(cucumber.runtime.StepDefinitionMatch) Around(org.aspectj.lang.annotation.Around) HookTestStep(cucumber.api.HookTestStep) PickleStep(gherkin.pickles.PickleStep) TestCaseFinished(cucumber.api.event.TestCaseFinished) Objects(java.util.Objects) CategoriesInjector(ru.sbtqa.tag.pagefactory.allure.CategoriesInjector) PickleStepTag(ru.sbtqa.tag.pagefactory.optional.PickleStepTag) Allure(io.qameta.allure.Allure) ReadFieldError(ru.sbtqa.tag.pagefactory.exceptions.ReadFieldError) Optional(java.util.Optional) FieldUtils.readDeclaredField(org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField) TestStep(cucumber.api.TestStep) ErrorHandler(ru.sbtqa.tag.pagefactory.allure.ErrorHandler) Collections(java.util.Collections) AllureStorage(io.qameta.allure.internal.AllureStorage) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Objects(java.util.Objects) TestResult(io.qameta.allure.model.TestResult) Map(java.util.Map) AllureStorage(io.qameta.allure.internal.AllureStorage)

Aggregations

HookTestStep (cucumber.api.HookTestStep)1 Result (cucumber.api.Result)1 TestCase (cucumber.api.TestCase)1 TestStep (cucumber.api.TestStep)1 TestCaseFinished (cucumber.api.event.TestCaseFinished)1 TestStepFinished (cucumber.api.event.TestStepFinished)1 StepDefinitionMatch (cucumber.runtime.StepDefinitionMatch)1 PickleStep (gherkin.pickles.PickleStep)1 Allure (io.qameta.allure.Allure)1 AllureStorage (io.qameta.allure.internal.AllureStorage)1 Status (io.qameta.allure.model.Status)1 TestResult (io.qameta.allure.model.TestResult)1 ResultsUtils.md5 (io.qameta.allure.util.ResultsUtils.md5)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 FieldUtils (org.apache.commons.lang3.reflect.FieldUtils)1