Hi,
I am trying to use the ServiceLoader Listeners to configure listeners but I can't get those listeners to ever be called when I run the tests with the eclipse plugin. Does the eclipse plugin work with the ServiceLoader?
When I use the eclipse runner for testNG on the code in the class below, the implementations of the services appear to be present, but they never get called while the test is running. Is there special configuration needed to make ServiceLoader listeners work with eclipse.
package com.example.testng.listener;
import java.util.ServiceLoader;
import org.testng.ISuiteListener;
import org.testng.ITestListener;
import org.testng.annotations.Test;
public class ExampleTest {
@Test
public void test1()
{
ServiceLoader<ISuiteListener> l = ServiceLoader.load(ISuiteListener.class);
for (ISuiteListener iSuiteListener : l) {
System.out.println("...... " + iSuiteListener);
}
ServiceLoader<ITestListener> l2 = ServiceLoader.load(ITestListener.class);
for (ITestListener iTestListener : l2) {
System.out.println("...... " + iTestListener);
}
System.out.println("ExampleTest.test1()");
}
Console Output.
[TestNG] Running:
/private/var/folders/9p/m_8sp30n15x2d93v1rd9fs3r0000gn/T/testng-eclipse-542005967/testng-customsuite.xml
...... com.example.testng.listener.ExampleSuiteListener@62725296
...... com.example.testng.listener.ExampleTestListener@498f3db0
ExampleTest.test1()
PASSED: test1
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@68f1e723: 8 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@7bd52240: 12 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@3a5f2465: 30 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@3f9c437d: 7 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@701f42b: 2 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms