allure-java icon indicating copy to clipboard operation
allure-java copied to clipboard

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

Open AhmdZanoon opened this issue 2 years ago • 5 comments

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

  • [X] I agree to follow this project's Code of Conduct

AhmdZanoon avatar Aug 29 '23 07:08 AhmdZanoon

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 avatar Aug 30 '23 12:08 dr29bart

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

AhmdZanoon avatar Aug 30 '23 12:08 AhmdZanoon

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.

baev avatar Oct 05 '23 17:10 baev

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

AhmdZanoon avatar Dec 05 '23 09:12 AhmdZanoon

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

dr29bart avatar Apr 02 '24 21:04 dr29bart