allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
357 stars 226 forks source link

🐞: Before Suite and AfterSuite steps not appearing in allure report anymore after version 2.21 #953

Open AhmdZanoon opened 1 year ago

AhmdZanoon commented 1 year ago

What happened?

after suite method not shown in allure report since version 2.22 for example below code

package allure;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Test;

import io.qameta.allure.Attachment;
import io.qameta.allure.Step;

public class TestClass {

       @BeforeSuite
    public void beforeSuite() {
        stepHasNestedSteps();
    }

    @BeforeMethod
    public void beforeMethod() {
        stepHasNestedSteps();
    }

    @Step("step has nested steps")
    public void stepHasNestedSteps() {
        callAttachment();
        callAttachment2();
    }

    @Attachment("attachment - nested ")
    public void callAttachment() {
        System.out.println("attachment");
    }

    @Step("another nested step")
    public void callAttachment2() {
        callAttachment();
    }

    @Test(description="description")
    public void test() {
    stepHasNestedSteps();

    }

    @AfterMethod(description ="after test")
    public void after(){
        stepHasNestedSteps();
    }

    @AfterSuite(description ="after Suit")
    public void afterSuit() {
        stepHasNestedSteps();
    }

}

latest version image

version 2.21 image

What Allure Integration are you using?

allure-testng

What version of Allure Integration you are using?

2.24.0

What version of Allure Report you are using?

2.24.0

Code of Conduct

dr29bart commented 1 year ago

To workaround a bug you can downgrade this dep:

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-generator</artifactId>
            <version>2.21.0</version>
        </dependency>

It also makes sense to move this issue to the main project

AhmdZanoon commented 1 year ago

To workaround a bug you can downgrade this dep:

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-generator</artifactId>
            <version>2.21.0</version>
        </dependency>

It also makes sense to move this issue to the main project @dr29bart you mean report it again , or you already did it

baev commented 1 year ago

Due to performance issues, we dropped support for recursive containers in Allure Report (it was never supported in Allure TestOps).

We must use separate containers for each test fixture to fix the issue.

AhmdZanoon commented 11 months ago

dear @baev any update on this one , or any missing data from my side , i'm still using version 2.21 as a workaround and i'm not able to generate single file because of this , your support is highly appreciated

dr29bart commented 7 months ago

Here is a workaround: by using custom listener create links between suite and test classes:

|_suite
|__textContext
|____TestClass
|_______testMethod
import io.qameta.allure.Allure;
import java.util.Objects;
import org.testng.ITestListener;
import org.testng.ITestResult;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

@Listeners(SampleTest.AllureTestNGListener.class)
public class SampleTest {

    @AfterSuite
    public void after() {
        Allure.step("after step");
    }

    @Test
    public void test() {
        Allure.step("test step");
    }

    public static class AllureTestNGListener implements ITestListener {
        @Override
        public void onTestStart(final ITestResult testResult) {
            Allure.getLifecycle().getCurrentTestCase()
                .ifPresent(testId -> {
                    var suite = testResult.getTestContext().getSuite();
                    var suiteId = Objects.toString(suite.getAttribute("ALLURE_UUID"));
                    Allure.getLifecycle().updateTestContainer(suiteId, container -> container.getChildren().add(testId));
                });
        }
    }
}

image