mardi 23 février 2021

@AfterClass and @beforeclass in testng executing twice

Hi I am practicing testng and I have a simple class as follows:

public class testclass1 {
    @Test
    public void firstMethod() {
        System.out.println("first");
    }
    
    @Test
    public void secondMethod() {
        System.out.println("second");
    }
    @Test
    @BeforeSuite
    public void thirdMethod() {
        System.out.println("third- before suite");
    }
    @Test
    @AfterClass
    public void fourthMethod() {
        System.out.println("fourth- after class");
    }
    
}

On execution, the results are

[RemoteTestNG] detected TestNG version 7.3.0
third- before suite
first
fourth- after class
second
third- before suite
fourth- after class

I am confused. Why is before suite and after class method invoked twice?

Aucun commentaire:

Enregistrer un commentaire