How to implement RunListener a JUnit Listener example

You may also like...

  • Nejc Dezelak

    Great tutorial!
    Note that notification) is actually the main execution method and is called only once so make sure you attach a Listener before calling it.

  • Buzz2Buzz

    Great, thanks.
    But I’ve got a question, this way it produces a report for each annotated class. How to avoid this and only have one report ?

  • Arjen den Hartog


    Why is the “testRunStarted” method not called?

    I am currently creating integration tests with JUnit. I want to setup the environment (e.g. init database with some data) in the

    testRunStarted() method.

  • vikesh pandey

    i have this scenario. I have declared a member variable in JUnitExecutionListener which is populated in testRunStarted(). Now i want to use this variable in one of Test classes(RunListenerTest in this case). How can i do that. There seems to be no way i can access any member of the listener in my tests. please help