What is difference b/w @BeforeClass and @BeforeTest annotation, both are used before @Test annotation.?

Answered

What is difference b/w @BeforeClass and @BeforeTest annotation, both are used before @Test annotation.?

Thanks

Train Asked on July 13, 2015 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)
    Best answer

    HI Vpn,

    Annotation @BeforeMethod: This method will be run before each test method.
    Annotation @BeforeClass : This method will be run before the first test method in the current class is invoked.
    Annotation @BeforeTest : This method will be run before any test method belonging to the classes inside the <test> tag is run.

    The hierarchy in TestNG will be like this

    Before Suite
    Beforeclass
    Beforemethod
    BeforeTest
    Test
    Aftertest
    Aftermethod
    Afterclass
    Aftersuite

    Thanks
    Suhabe

    Train Answered on July 13, 2015.
    Add Comment

    Thanks Suhabe_Shaikh

    Train Answered on July 13, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.