Can't get ServiceLoader listeners to work with the eclipse runner

283 views
Skip to first unread message

adib.s...@gmail.com

unread,
Mar 25, 2014, 4:36:13 PM3/25/14
to testng...@googlegroups.com
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

Krishnan Mahadevan

unread,
Mar 26, 2014, 4:05:06 AM3/26/14
to testng...@googlegroups.com
I think you should be following the instructions detailed by Cedric in this post : https://groups.google.com/forum/#!msg/testng-users/ZVloM26gEoI/wxummGZh7YIJ

to use ServiceLoaders and load TestNG listeners.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages