1.1. Example of IExecutionListener





1.1. Example of IExecutionListener


IExecutionListener is a listener that monitors the beginning and end of a TestNG run. It has two methods,onExecutionStart() and onExecutionFinish(). Method onExecutionStart() is called before the TestNG starts running the suites and onExecutionFinish() is called after TestNG is done running all the test suites.
In the below example, we will create two IExecutionListener listeners, ExecutionListener1 and ExecutionListener2. In classExecutionListener1, in method onExecutionStart()
Example  Demo :




In the output, you can see one set of messages are printed before TestNG starts running the suites and the other set of messages are printed once all the suites have been run.
Output :
Starting On execution test from ExecutionListener1
Starting On execution test from ExecutionListener2
[TestNG] Running:


Am in Before Suite
In Test Method t...

===============================================
Suite
Total tests run: 1, Failures: 0, Skips: 0








No comments:

Post a Comment

Note: Only a member of this blog may post a comment.