Katalon Studio
What is Katalon Studio?
Katalon Features
Katalon SetUp
Katalon Studio Toolbars and Views
Katalon Main Toolbar
Test Explorer in Katalon
Keywords Browser in Katalon
Editors/Views in Katalon
Create Test Case in Katalon Studio
Steps to create Test case
Record and Play in Katalon
Manual Mode in Katalon
Script Mode in Katalon
Test Suite in Katalon Studio
What is a test suite?
Steps to create test suite
Test suite execution settings
Test Suite Collection in Katalon Studio
What is a test suite Collection?
Steps to create test suite Collection
Test suite Collection execution settings
Execution Profile in Katalon Studio
Create New Profile in Katalon
How To Use Profile in Katalon
Set Default Profile in Katalon
Data Driven testing in Katalon Studio
Global Variables in Katalon
Test Case Variables in Katalon
Data files and Binding
Using custom keywords to Read Files in Katalon
Data files/Read Files in Katalon Studio
How to read data from excel file in Katalon Studio
How to read data from CSV file in Katalon Studio
How to read data from internal files in Katalon Studio
How to read data from Database in Katalon
Data Binding of test cases in Katalon Studio
Import Test Data from External Excel/ CSV file
How to create a Test Suite?
Manage Data Binding to Test suite
Test Listener/Hooks in Katalon Studio
What are Test Listeners in Katalon?
How to create new Test Listeners
Execution With Test Listener example and flow
Test Listeners / Test Hooks in Katalon Studio
Test Listeners in Katalon Studio is block of code that run before or after each Test Case or Test Suite executed.
This allows us to manage the code workflow better and helps to reduce code redundancy.
In this article we will cover below topics:
What are Test Listeners ( Test Hooks ) in Katalon Studio?
-
- Test steps created based on your own criteria of execution , a useful and flexible way to help you extend your current testing flows are known as Test Listeners.
- Â Katalon Provides Test Listeners that can be used to achieve this.
- Helps reduce code redundancy and make code look cleaner.
How to create new Test Listeners
To create new Test Listeners or setting it for the first time, follow below steps:
STEPS:
-
- In the Test Explorers view, you can see Test Listeners. Right click on Test Listeners.
- Navigate to New → New Test Listener.
3. New Test Listener dialog box opens. Enter the name of the Test Listener. Also it gives a checkbox option to create sample Before and After Test case and Test Suite methods.
Select any or all check boxes and click on OK.
Below is the brief description about options in dialog box
4. Sample template is generated. We can modify it as per our execution needs. //code displayed asÂ
class NewTestListener_1 { /** * Executes before every test case starts. * @param testCaseContext related information of the executed test case. */ @BeforeTestCase def sampleBeforeTestCase(TestCaseContext testCaseContext) { println testCaseContext.getTestCaseId() println testCaseContext.getTestCaseVariables() } /** * Executes after every test case ends. * @param testCaseContext related information of the executed test case. */ @AfterTestCase def sampleAfterTestCase(TestCaseContext testCaseContext) { println testCaseContext.getTestCaseId() println testCaseContext.getTestCaseStatus() } /** * Executes before every test suite starts. * @param testSuiteContext: related information of the executed test suite. */ @BeforeTestSuite def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) { println testSuiteContext.getTestSuiteId() } /** * Executes after every test suite ends. * @param testSuiteContext: related information of the executed test suite. */ @AfterTestSuite def sampleAfterTestSuite(TestSuiteContext testSuiteContext) { println testSuiteContext.getTestSuiteId() } }
Test Execution With Test Listener example and flow
Example that shows how execution flow works:
-
- Create a Test Suite that has test cases in it.
2. As shown in above code, create a Test Listener.
3. Run the Test Suite and see the console.
   Recommended Articles
Katalon Studio
Katalon Features
Katalon SetUp
Katalon Studio Toolbars and Views
Katalon Main Toolbar
Test Explorer in Katalon
Keywords Browser in Katalon
Editors/Views in Katalon
Create Test Case in Katalon Studio
Steps to create Test case
Record and Play in Katalon
Manual Mode in Katalon
Script Mode in Katalon
Test Suite in Katalon Studio
What is a test suite?
Steps to create test suite
Test suite execution settings
Test Suite Collection in Katalon Studio
What is a test suite Collection?
Steps to create test suite Collection
Test suite Collection execution settings
Execution Profile in Katalon Studio
Create New Profile in Katalon
How To Use Profile in Katalon
Set Default Profile in Katalon
Data Driven testing in Katalon Studio
Global Variables in Katalon
Test Case Variables in Katalon
Data files and Binding
Using custom keywords to Read Files in Katalon
Data files/Read Files in Katalon Studio
How to read data from excel file in Katalon Studio
How to read data from CSV file in Katalon Studio
How to read data from internal files in Katalon Studio
How to read data from Database in Katalon
Data Binding of test cases in Katalon Studio
Import Test Data from External Excel/ CSV file
How to create a Test Suite?
Manage Data Binding to Test suite
Test Listener/Test Hooks in Katalon Studio
What are Test Listeners in Katalon?
How to create new Test Listeners
Execution With Test Listener example and flow