Annotation Transformer "global context"

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

Annotation Transformer "global context"

dchaffiol

Hi,
When one implement the method
public void transform(ITest annotation, Class testClass, Constructor
testConstructor, Method testMethod)
'annotation' represents a kind of local 'context' (local to the
Method): the annotations characterize the Method itself (dependent
groups, dependent methods, and so on)

But what about the Test itself, which could represent a 'global
context' (excluded and included groups, classes, method names declared
in a given xml testng file) ?

That could be useful especially if I want to modify annotations of a
method only if a certain group or class has be mentioned (included /
excluded) within my suite.xml file.

When transform() is called (for the first time from
TestRunner.initMethod() withinTestRunner.init()), TestRunner.m_xmlTest
has been valued and contains informations that could be exploited
during the annotation transformer decision process.

So I would like an interface similar to ITest allowing me to access to
the **declared** (declared within the xmltest file) list of (included /
excluded) groups, classes, method). That interface would be a new
argument passed to the 'transform' method.

Again, that interface would only access to the declared items in a
testng suite xml file, not to the **calculated** list of included /
excluded groups, classes, methods, since that computation  only takes
place after the TestRunner initialization, and involves closure
determinations (implying that TestRunner knows about all groups,
classes, methods)

Actually, it already exists (kind of): ITestContext plays that role in
the methods onStart or onFinish within a ITestListener... but, that
kind of Listener is only called after TestRunner.init() (which has
already called about 10 times the annotation transformers of methods
involved): it is too late.

Concrete scenario (testng 5.3 or 5.4):
* I have a method 'm' which depend on another group 'g'
* In my  testng xml file, I declared that group 'g' as excluded
* If I make no annotation transformation, my method 'm' will be skipped
(because "Method 'm' depends on nonexistent group", from
org.testng.internal.Invoker.invokeTestMethods())
* If I want to remove that group dependency, I can do it through a
annotation transformer (and 'm' will not be skipped), but I have no way
to know if that group was declared excluded or not.

Does that make sense ? Is there already a way to do that ?


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