Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
Custom listeners

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 -

  1. Create class which extends ServicesAware and implements interface Provider<T>
    Where T is listener type (all types: Listener)
    public class ProviderOfTestSuiteListener extends ServicesAware implements Provider<TestSuiteListener> {

  2. 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 -->

  3. Add reference to your listener to appropriate block of your XML schema
    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-group-decision-maker-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