Listeners main page
You can implement different types of listeners (Listener) depending on your requirements.
Approach for implementation will be always the same like described below.
To add custom listener (f.e. test suite listener) you need to do -
- Create class which extends ServicesAware and implements interface Provider<T>
public class ProviderOfTestSuiteListener extends ServicesAware implements Provider<TestSuiteListener> {
- Create bean in XML file with some id
<!-- begin: following section is used for docu generation - listener usage -->
<bean id="listenerTestSuite" class="${package}.listener.ProviderOfTestSuiteListener"/>
<!-- end: following section is used for docu generation - listener usage -->
Important. For invocation listener bean scope is important.
When scope="prototype" is set separate object will be created for exevy test in your XML configuration
<!-- begin: following section is used for docu generation - invocation listener usage -->
<bean id="listenerInvocation" class="${package}.listener.ProviderOfInvocationListener" scope="prototype"/>
<!-- end: following section is used for docu generation - invocation listener usage -->
- Add listener-test-suite-ref to test-suite block
in your configuration XML file and set id of listener to attribute ref. <!-- begin: following section is used for docu generation - test suite listener usage -->
<!-- Custom test suite listener will be executed on test suite start and stop -->
<listeners-test-suite>
<listener-test-suite xsi:type="listener-test-suite-ref" ref="listenerTestSuite"/>
</listeners-test-suite>
<!-- end: following section is used for docu generation - test suite listener usage -->
listener-test-suite-ref belongs to test-suite block in XML
listener-test-group-ref belongs to test-group block in XML
listener-test-ref belongs to test block in XML
listener-invocation-ref belongs to info-collectors block in XML
Note:
- full examples of the code are available in maven archetype-examples or here: Custom listener examples code
- instead of ${package} write the name of your package