Writing Listener in NetBeans IDE

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Writing Listener in NetBeans IDE

I'm new to Java, NetBeans & TestNg so am pretty overwhelmed right now.  I copied an existing listener (with slight tweaks to the strings so I didn't have to worry about getting the code wrong) and added it to the Test Packages section of the project.  I made the strings longer so I wouldn't miss them since surefire plugin is installed and I get a lot of output.  The code and test code already exist and are working.  I'm trying to get to the point where I can add the test case results to Rally.

So I created RallyListener.java in the Test Packages folder with the tests and Testxx.xml definitions which contains:
package com.x.rest;

import org.testng.TestListenerAdapter;
import org.testng.ITestResult;

public class RallyListener extends TestListenerAdapter {
  private int m_count = 0;

  public void onTestFailure(ITestResult tr) {
    log(" Failed ");

  public void onTestSkipped(ITestResult tr) {
    log(" Skipped ");

  public void onTestSuccess(ITestResult tr) {
    log(" Passed ");

  private void log(String string) {
    if (++m_count % 40 == 0) {

I modified the testng.xml (which in my case is actually TestDeviceSuite.xml) and added:
        <listener class-name="RallyListener" />

This file is specified in the POM:
Even though I have hidden files & folders configured to show, I can't see the nb-private folder in the target directory so don't quite know the magic that is making the tests run since the file names don't match.

I also found a place that indicated I could configure the listener in the POM and tried that as well but also to no avail.

From everything I've read, it should work but it isn't.  The system also has the surefire plugin installed and I suspect it may be using the same annotations but other reading made me believe that is ok.  Is there anything I've missed?  Or have I put something in the wrong place?  This is all new and VERY confusing!  Other examples suggest running things from the command line (and that's a great idea) but it doesn't work so I'm guessing there are paths set up in the IDE that aren't in my DOS environment variables.  I'm running Win7 (64-bit).

Thanks so much for any and all help.

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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.