I want to use my own RunListener
on my unit tests. So I've created the following class:
public class MyRunListener extends RunListener {
public MyRunListener() {
System.out.println("Creation of Run Listener...");
}
@Override
public void testStarted(Description description) throws Exception {
System.out.println("A Test is going to start");
}
}
Now, in my pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<properties>
<property>
<name>listener</name>
<value>my.company.MyRunListener</value>
</property>
</properties>
</configuration>
</plugin>
Now, when I run mvn test
in my project, the output is the following:
Creation of Run Listener...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running xxx.SomeNewTests
Test New #1
Test New #2
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.109 sec
Running xxx.SomeErrorTests
Test Old #1
Test Old #2
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.125 sec <<< FAILURE!
Results :
Failed tests:
testOldOne(xxx.SomeErrorTests)
testOldTwo(xxx.SomeErrorTests)
Tests run: 4, Failures: 2, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
So as you can see, my RunListener is created, but never called during tests execution.
What did I missed?
Technical information: Java 6, Maven 3.0.2, JUnit 4.8.1