O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Before and After annotation when extended

  1. Open eclipse and create a Java project with a package structure as mentioned below. Make sure that you have added TestNG library to the build path.
    Time for action – Before and After annotation when extended
  2. Add the following code to the BaseClass.java file:
    package test.beforeafter; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; public class BaseClass { @BeforeClass public void beforeBaseClass(){ System.out.println("Parent Before Class method"); } @AfterClass public void afterBaseClass(){ System.out.println("Parent After Class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required