MorkPuncher MorkPuncher - 1 month ago 5x
Java Question

TestNG global @AfterMethod

In java TestNG is it possible to somehow specify a global (or suite wide) method with

The goal is to have different test cases in separate classes(so that 1 file = 1 test) but to also have a common
without duplicating the method in every class.


You can achieve this by making a superclass. Example:

public class BasicTestScenario {

  public void tearDown() {
    // your implementation

Then have your tests inherit this class.

public class MyTest extends BasicTestScenario {
// your test