Time for action – running the Before and After annotations

  1. Perform the following steps to run the Before and After annotations: Open Eclipse and create a Java Project with following structure. Please make sure that TestNG library is added to the build path of the project as mentioned in Chapter 1, Getting Started.
    Time for action – running the Before and After annotations
  2. Add the following code to the TestClass.java file shown in the previous screenshot:
    package test.beforeafter; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; ...

Get TestNg Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.