MorkPuncher MorkPuncher - 1 year ago 150
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download