Available since Katalon Studio v5.2
Test Listeners is a new feature of Katalon Studio introduced since version 5.2. It is a great and flexible way to help you extend your current testing flows. In simple term, Test Listeners are test steps that created based on your own criterias and will be executed when the condition is matched. The follwing guide contains all useful information to get you started with Test Listeners.
Manage Test Listeners
Test Listeners can be treated the same as other test artifacts, which means you can perform all basic operations such as create, copy/cut, rename or delete. We will not talk much about these actions except Create one. Test Listeners locate in Test Explorer pane. To create New Test Listener:
Right click on Test Listeners in Tests Explorer. Select New > New Test Listener.
When creating a new test listener, you can see there are 4 options in New Test Listener dialog:
|Generate sample Before Test Case method||A sample listener will be generated before every test case starts.|
|Generate sample After Test Case method||A sample listener will be generated after every test case ends.|
|Generate sample Before Test Suite method||A sample listener will be generated before every test suite starts.|
|Generate sample Before Test Suite method||A sample listenerwill be generated after every test suite ends.|
You can select one or multiple options. Once finished, Katalon Studio will generate a sample template accordingly:
As you can see from the code above, a sample generated template has already added necessary annotations, libraries and supported functions to help you extend your current testing flows to a higher level.
- There is no limit on Test Listeners. Users can create as many as preferred.
- If you have more than one Test Listener class, the classes themselves are instantiated in Katalon storage in alphabetically order, only then are the individual listener methods executed top-down.
- Execution status of any steps within Test Listers will NOT affect the overall status of the executed test case (e.g: if you have a FAILED output in any of your Test Listeners but final status of the executed test case is PASSED, then test case's status will be PASSED).
To not get confused with setUp and tearDown, the visualized workflows below demonstrate how Katalon Studio will execute test automation project with/without setUp and tearDown methods.
Define multiple environments as different Global Variables by using Test Listeners. Simply change the environment variable to the preferred environment before test case execution.