Is @Test annotation on class compatible with IHookable?

150 views
Skip to first unread message

Tim Boemker

unread,
Mar 1, 2013, 3:10:33 PM3/1/13
to testn...@googlegroups.com
The TestNG documentation says this:

The @Test annotation can be put on a class instead of a test method.  The effect of a class level @Test annotation is to make all the public methods of this class to become test methods even if they are not annotated.

Is it possible for a class with an @Test annotation to implement IHookable?  Because run(IHookCallBack callBack, ITestResult testResult) is public, TestNG tries unsuccessfully to run it as a test method.

Is there a way to tell TestNG to ignore this method?

Cédric Beust ♔

unread,
Mar 1, 2013, 3:45:12 PM3/1/13
to testn...@googlegroups.com
Not really. The usual way to do this is to make the method protected but it's not an option here since you are implementing an interface. Either put it in a different class or maybe an inner class? (although it might still be captured by the class-level @Test annotation, not 100% sure).

-- 
Cédric


-- 
Cédric




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

Tim Boemker

unread,
Mar 5, 2013, 1:44:40 PM3/5/13
to testn...@googlegroups.com, ced...@beust.com
I don't see how it can be put in a different class, or an inner class.  To be useful, it has to be implemented in the test class:

If a test class implements this interface, its run() method will be invoked instead of each @Test method found.
Reply all
Reply to author
Forward
0 new messages