Neither ITestListener, nor ISuiteListener, contain methods for <test> start/end

69 views
Skip to first unread message

Kayla Nimis

unread,
Oct 7, 2011, 2:53:58 PM10/7/11
to testng...@googlegroups.com
Hi,

I'm currently trying to implement a test listener that reads in a file, based on a test parameter, and uses it in the onTestStart(ITestResult) method to determine whether or not to skip the method. However, it appears that there is no hook for when you start or finish a suite's test. I'm currently tracking the context.getCurrentXmlTest().getName() value in my listener, and only reading the file when that value changes. I was wondering if there was a less hacky way, or if it is in the works.

Thanks,
Kayla

Kevin Simonson

unread,
Oct 7, 2011, 3:54:43 PM10/7/11
to testng...@googlegroups.com

Currently the contents of my “testng.xml” file are:

 

<suite name=”clTest”>

  <test name=”clTest”>

    <classes>

      <class name=”org.familysearch.cds.acceptance.CollectionEndpointTest”>

        <methods>

          <include name=”getCollectionSummary” />

          <include name=”updateCollection” />

        </methods>

      </class>

    </classes>

  </test>

</suite>

 

This lets me test these two test methods, which are both in the group I designate as “middle-phase”.  Now I could just add to this the name of all the other test methods in this class that belong to group “middle-phase” (there are two more of them), but is there an easier way to tell “testng.xml” I want to test all test methods in a class that belong to a specific group?

 

Kevin Simonson

 



NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


P. Hill

unread,
Oct 7, 2011, 4:03:07 PM10/7/11
to testng...@googlegroups.com
On 10/7/2011 12:54 PM, Kevin Simonson wrote:

Currently the contents of my “testng.xml” file are:

 

<suite name=”clTest”>

  <test name=”clTest”>

    <classes>

      <class name=”org.familysearch.cds.acceptance.CollectionEndpointTest”>

        <methods>

          <include name=”getCollectionSummary” />

          <include name=”updateCollection” />

        </methods>

      </class>

    </classes>

  </test>

</suite>

 

This lets me test these two test methods, which are both in the group I designate as “middle-phase”.  Now I could just add to this the name of all the other test methods in this class that belong to group “middle-phase” (there are two more of them), but is there an easier way to tell “testng.xml” I want to test all test methods in a class that belong to a specific group?

 



You speak in group terms, so isn't testNGs groups (with include and exclude) just the ticket?

class X {


@Test( group="middle-phase" )

public void getCollectionSummary() {

}


}


Test grouping can be done at the class level also; see docs.

<suite name=”clTest”>

  <test name=”clTest”>
    <package>

        <package name="org.familysearch.cds.acceptance" />
    </package>
    <groups>
      <run>
         <include name="middle-phase"/>
      </run>
    </groups>

  </test>
</suite>

Cédric Beust ♔

unread,
Oct 7, 2011, 4:03:49 PM10/7/11
to testng...@googlegroups.com
How about:

    <groups>
      <run>
        <include name="foo"/>
      </run>
    </groups>

?

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Cédric Beust ♔

unread,
Oct 7, 2011, 4:13:03 PM10/7/11
to testng...@googlegroups.com
How about onTestSuccess()?

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/PQEzAbpTl7kJ.

Kevin Simonson

unread,
Oct 7, 2011, 4:14:54 PM10/7/11
to testng...@googlegroups.com

This looks encouraging, but I have test methods in another class in my “org.familysearch.cds.acceptance” package that are in the “middle-phase” group.  Won’t they be picked up by this XML?  What do I do to get just the test methods in the one class that are in the “middle-phase” group?

 

Kevin Simonson

--

You received this message because you are subscribed to the Google Groups "testng-users" group.

To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Cédric Beust ♔

unread,
Oct 7, 2011, 4:37:46 PM10/7/11
to testng...@googlegroups.com
Then just include that class in your XML file.

-- 
Cédric

Kayla Nimis

unread,
Oct 7, 2011, 6:11:24 PM10/7/11
to testng...@googlegroups.com
Is there something similar for when it starts?

Cédric Beust ♔

unread,
Oct 7, 2011, 6:14:22 PM10/7/11
to testng...@googlegroups.com
onTestStart()?

-- 
Cédric




On Fri, Oct 7, 2011 at 3:11 PM, Kayla Nimis <kayla...@gmail.com> wrote:
Is there something similar for when it starts?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/9v9K9xaWdZEJ.

Kevin Simonson

unread,
Oct 7, 2011, 6:58:52 PM10/7/11
to testng...@googlegroups.com

Okay, following Cedric’s advice (or at least I thought I was), I created “testng.xml” file:

 

<suite name=”clTest”>

  <test name=”clTest”>

    <classes>

      <class name=”org.familysearch.cds.acceptance.CollectionEndpointTest”>

      </class>

      <groups>

        <run>

          <include name=”middle-phase” />

        </run>

      </groups>

    </classes>

  </test>

</suite>

 

When I right click in this file and select <Debug “C:/Sandbox/sourceCode4/cds2-root/cds-acceptance-tests/src/test/testng/testng.xml”>, execution begins in <getCollSummParms()>, the data provider of my test method <getCollectionSummary().  But this class has a method <setUp()> with the “@BeforeClass” annotation before it!  Why isn’t <setup()> getting called?  Anyone have any ideas?

 

Kevin S

 

From: testng...@googlegroups.com [mailto:testng...@googlegroups.com] On Behalf Of Cédric Beust ?
Sent: Friday, October 07, 2011 2:38 PM
To: testng...@googlegroups.com
Subject: Re: [testng-users] Telling TestNG I Want to Run all Test Methods in a Class

 

Then just include that class in your XML file.


-- 

Cédric



On Fri, Oct 7, 2011 at 1:14 PM, Kevin Simonson <simon...@familysearch.org> wrote:

This looks encouraging, but I have test methods in another class in my “org.familysearch.cds.acceptance” package that are in the “middle-phase” group.  Won’t they be picked up by this XML?  What do I do to get just the test methods in the one class that are in the “middle-phase” group?

 

Kevin Simonson

 

Cédric Beust ♔

unread,
Oct 7, 2011, 7:09:18 PM10/7/11
to testng...@googlegroups.com
Probably because it's not in the group. This is explained in details in the documentation (along with "alwaysRun").

-- 
Cédric




Reply all
Reply to author
Forward
0 new messages