Package org.testng

Interface IMethodInterceptor

  • All Superinterfaces:
    ITestNGListener

    public interface IMethodInterceptor
    extends ITestNGListener
    This class is used to alter the list of test methods that TestNG is about to run.

    An instance of this class will be invoked right before TestNG starts invoking test methods. Only methods that have no dependents and that don't depend on any other test methods will be passed in parameter. Implementers of this interface need to return a list of IMethodInstance that represents the list of test methods they want run. TestNG will run these methods in the same order found in the returned value.

    Typically, the returned list will be just the methods passed in parameter but sorted differently, but it can actually have any size (it can be empty, it can be of the same size as the original list or it can contain more methods).

    The ITestContext is passed in the intercept method so that implementers can set user values (using IAttributes.setAttribute(String, Object)), which they can then look up later while generating the reports.