You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Matt Hughes <mh...@chariotsolutions.com> on 2007/12/20 17:58:19 UTC

TestListeners with Surefire

TestNG has the concept of a TestListener that gets notified
before/after each test run.  JUnit has the same thing I believe.
(http://testng.org/javadocs/org/testng/TestNG.html)

I have tried everything I could to pass the listener class into
Surefire to no avail.  I tried
* adding listener property in my profile
* adding entry to surefire plugin config
* adding -Dlistener=Foo when running Maven

None of these work as of Surefire 2.4.  I checked out the Surefire
sourcecode and found this code:

TestNGExecutor.java
public static void run( List suiteFiles, String testSourceDirectory,
Map options, ArtifactVersion version,
                        String classifier, ReporterManager
reportManager, SurefireTestSuite suite, File reportsDirectory )
    throws TestSetFailedException
{
    TestNG testng = new TestNG( false );
    Configurator configurator = getConfigurator( version );
    configurator.configure( testng, options );
    postConfigure( testng, testSourceDirectory, (String)
options.get("listener"), classifier, reportManager, suite,
reportsDirectory );

    testng.setTestSuites( suiteFiles );
    testng.run();
}

TestNGExecutor looks for a "listener" entry in the options map (which
then actually attaches the listener further on) but from what I can
tell, the class that calls the executor, SurefirePlugin.java, never
puts that key in the map:

http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?revision=605713&view=markup

Look specifically at #convertTestNGParameters()



Is this a bug?  Or has anyone ever configured a TestNG TestListener
class through Surefire?



Thanks,
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org