allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
355 stars 224 forks source link

🐞: setStatus not updated status and stopStep destroys nesting of steps #1133

Open VaXoID55 opened 2 days ago

VaXoID55 commented 2 days ago

What happened?

Example Test:

public class MyTest {
    @Rule
    public Timeout globalTimeout = new Timeout(10, TimeUnit.MINUTES);

    @Test
    @DisplayName("ExampleTestName")
    public void MyTes_1() {
        simpleStep();
    }

    @Step("Inner step")
    private void innerStep(boolean result) {
        Utils.sleep(200);
        StepUtils.setStepStatus(result);
    }

    @Step("Outer step")
    public void simpleStep() {
        step("Simple step");
        step("Simple step with status", Status.FAILED);
        innerStep(true);
        innerStep(false);
        innerStep(true);
        innerStep(false);
    }
}

If use setStepStatus as:

public static boolean setStepStatus(boolean status) {
    if (!status) {
        Allure.getLifecycle().updateStep(result ->
                result.setStatus(Status.FAILED));
        Allure.getLifecycle().stopStep();
    }
    return status;
}

then all nested steps after FAILED cease to be nested, but status step set correctly: image If use setStepStatus as (without stopStep()):

public static boolean setStepStatus(boolean status) {
    if (!status) {
        Allure.getLifecycle().updateStep(result ->
                result.setStatus(Status.FAILED));
    }
    return status;
}

the nesting of steps is correct, but the status is not set to FILED image

What Allure Integration are you using?

allure-junit4

What version of Allure Integration you are using?

2.29.0

What version of Allure Report you are using?

2.29.0

Code of Conduct