Friday, October 26, 2018

What is the use of TestNG Listeners?

As the name "Listeners" indicating they listen to some events and act accordingly. TestNG provides some interface that will help us to do certain tasks that before and after Suite or Test execution, these interfaces are nothing but TestNG Listeners.

TestNG Listeners are mainly used in generating customized reports and logs. Below are the list of listeners provided TestNG. Each interface is having different abstract methods which can be overridden as per our requirement.

  • IExecutionListener
    • This TestNG Listener monitors the begining and ending of the TestNG run. This has two methods onExecutionStarts() and onExecutionEnd(). onExecutionStarts() method will be invoked before TestNG starts executing the test suites and onExecutionEnd() method will be invoked after TestNG finishes executing all the test suites.
  • IAnnotationTransformer
    • This TestNG Listener allows us to modify TestNG annotations and configure further.
  • IInvokedMethodListener
    • This TestNG Listener is for all the methods. It will be invoked before and after of any method of TestNG.
  • IMethodInterceptor
    • This TestNG Listener is used to modify the list of test methods to be run in TestNG. We can select group of test methods from the given list using this and ignore other test methods.
  • IHookable
    • This TestNG Listener is used to implement your test methods with specific security manager. If a test class implements this interface, its run() method will be invoked instead of each @Test method found.
  • IReporter
    • This TestNG Listener is used for generating the report at the end of test suite execution.
  • ISuiteListener
    • This TestNG Listener is for test suite and this listener contains two methods onStart() and onFinish(). onStart() method will be invoked before executing the Suite and onFinish() will be invoked at the end of the Suite execution.
  • ITestListener
    • This TestNG Listener is for test method and this contains methods onStart(), onFinish(), onTestSuccess(), onTestFailure(), onTestSkipped() and onTestFailedButWithinSuccessPercentage().
In the next posts we will see the implementations of the some of the above listeners for better understanding.

Please comment your suggestions or queries on this post. Thanks for reading. #HappyTesting #HappyLearning #QABABU

2 comments:

  1. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training Hyderabad blog

    ReplyDelete
  2. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

    ReplyDelete

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...