Allure Framework: TestNG adapter incorrectly puts @AfterMethod in report

I am using allure V1.4.8 + TestNG. It seems that the TestNG adapter incorrectly puts @AfterMethod in the report - basically it puts AfterMethod from the test case in the next test file.

Here is a simple code:

    @Step("a test1")
    @Test
    public void Test1(){
    }

    @Step("a test2")
    @Test
    public void Test2(){
    }

    @Step("before method")
    @BeforeMethod
    public void beforeMethod(){     
    }

    @Step("after method")
    @AfterMethod
    public void methodCleanup()
    {   
    }

And here is the generated report:

<test-cases>
    <test-case start="1424347388060" stop="1424347388730" status="passed">
        <name>Test1</name>
        <steps>
            <step start="1424347388011" stop="1424347388014" status="passed">
                <name>before</name>
                <title>before test</title>
                <attachments/>
                <steps/>
            </step>
            <step start="1424347388036" stop="1424347388036" status="passed">
                <name>beforeMethod</name>
                <title>before method</title>
                <attachments/>
                <steps/>
            </step>
            <step start="1424347388067" stop="1424347388067" status="passed">
                <name>Test1</name>
                <title>a test1</title>
                <attachments/>
                <steps/>
            </step>
        </steps>
        <labels>
            <label name="host" value=""/>
            <label name="thread" value=""/>
        </labels>
    </test-case>
    <test-case start="1424347388747" stop="1424347389056" status="passed">
        <name>Test2</name>
        <steps>
            <step start="1424347388739" stop="1424347388739" status="passed">
                <name>methodCleanup</name>
                <title>after method</title>
                <attachments/>
                <steps/>
            </step>
            <step start="1424347388746" stop="1424347388746" status="passed">
                <name>beforeMethod</name>
                <title>before method</title>
                <attachments/>
                <steps/>
            </step>
            <step start="1424347388750" stop="1424347388750" status="passed">
                <name>Test2</name>
                <title>a test2</title>
                <attachments/>
                <steps/>
            </step>
        </steps>

     </test-case>
</test-cases>
+4
source share
1 answer

This is a TestNG adapter issue. In this adapter we use ITestListener listener and onTestSuccess, onTestFailure, onTestFailedButWithinSuccessPercentageand onTestSkippedmethods for the test mark as a complete. But TestNG calls methods before @AfterMethod .

, befores afters (, , IInvokedMethodListener). .

,

Update

Allure TestNG . Allure 2. . https://docs.qameta.io/allure/2.0/#_testng

+1

All Articles