3

I'm trying to write a custom Junit RunListener, to be called by Surefire when executing tests. My listener should create some custom 'events' to be sent through Maven's EventSpyDispatcher, so that these can get picked up by an event spy that I also created.

My CustomTestRunListener lives in a separate jar that is added to the test scope classpath of Surefire. My listener looks like this

@Component(role = RunListener.class)
public class CustomTestRunListener extends RunListener {

    @Requirement
    EventSpyDispatcher eventSpyDispatcher;

    public CustomTestRunListener() {
        System.out.println("CustomTestRunListener created");
        System.out.println(eventSpyDispatcher);
    }

    @Override
    public void testRunStarted(Description description) throws Exception {
        System.out.println("testRunStarted");
    }
}

It it wired successfully in Surefire, because I can see my System.out statements being printed.

But the eventSpyDispatcher is not injected (the sytem out on it is 'null') How can I achieve this ?

facewindu
  • 705
  • 3
  • 11
  • 31

0 Answers0