Selenium TestNG get started Method 1 & execution hierearchy


  • Create new sample test class with TestNG and run for understanding the execution

package com.test.practice;

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

public class NewTest {
  @Test
  public void f() {
  System.out.println("TEst method");
  }
  @BeforeMethod
  public void beforeMethod() {
  System.out.println("before method"); 
  }

  @AfterMethod
  public void afterMethod() {
  System.out.println(" after method");
  }

}


Output:[RemoteTestNG] detected TestNG version 6.14.2
before method
TEst method
 after method
PASSED: f

Below is the execution hierarchy for the TESTNG 



  1. before Test suite
  2. before Test
  3. before Class
  4. before Method
  5. TEST METHODS
  6. After method
  7. After class
  8. After test
  9. After Test Suite

Comments

Popular Posts