allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
342 stars 219 forks source link

🐞: Could not update test case: test case with uuid" when using it in second or futher steps of cucumber scenario/background #1008

Closed bigkingkosta closed 3 months ago

bigkingkosta commented 4 months ago

What happened?

Using methods Allure.descriptionHtml ,Allure.link or Allure.label in first step of a scenario or first step of the background in feature file works. But using it in second and further steps the following error occurs; [main] ERROR io.qameta.allure.AllureLifecycle - Could not update test case: test case with uuid Logging the current testcase uuid (findUuidInString(Allure.getLifecycle().getCurrentTestCase().get()) shows that the uuid change from "Options[uuid]", to featureNameOptions[uuid]scenarioStepName. Using workaround for ongoing that works:

a) Instead of using e.g. Allure.descriptionHtml I use: code snipped(adapted from the Allure.descriptionHtml method):

if (Allure.getLifecycle().getCurrentTestCase().isPresent()) {
            String currentUuid=findUuidInString(Allure.getLifecycle().getCurrentTestCase().get());
            logger.debug("currentUuid :{}",currentUuid);
                getLifecycle().updateTestCase(currentUuid, (execute) ->
                        execute.setDescriptionHtml(("\<p\>test\</p\>")));
        }

b) via regular expression I extracted the uuid public static String findUuidInString(String findString){

    Matcher matcher = Pattern.compile( "[0-9a-f\\-]{8}-[0-9a-f\\-]{4}-[0-9a-f\\-]{4}-[0-9a-f\\-]{4}-[0-9a-f\\-]{12}" ).matcher( findString );
    String match="";
    while ( matcher.find() ) {
        logger.debug("searchString : {} an Position [{},{}]",
                matcher.group(),
                matcher.start(), matcher.end());
        match=matcher.group();
    }
    return match;
}

What Allure Integration are you using?

allure-cucumber7-jvm

What version of Allure Integration you are using?

2.25.0

What version of Allure Report you are using?

2.25.0

Code of Conduct

baev commented 4 months ago

The problem is that hook steps after finish clears the thread context. The fix https://github.com/allure-framework/allure-java/pull/1011