AnnotationTransformer called for methods not selected

18 views
Skip to first unread message

Thomas H

unread,
Jun 13, 2017, 9:43:15 AM6/13/17
to testng-users
Hi,

I use the IAnnotationTransformer to disable test cases in run-time, based on criteria annotated on the test methods.

If the suite XML file lists individual test methods, like this:

<test name="My test">
<classes>
<class name="MyTestClass">
<methods>
<include name="myTestMethod1"></include>
</methods>
</class>
...

then the transformer is called for all test methods in the class (MyTestClass).
This is problematic for me. I would like the transformer to only be called for the test methods that are going to run.

Is this how it is intended? Can it be changed?

Is there a way for me to know in the transformer if the method is selected by the suite XML?


/Thomas

Krishnan Mahadevan

unread,
Jun 14, 2017, 1:19:59 AM6/14/17
to testng...@googlegroups.com

Cedric/Julien,

Do you think we should change AnnotationTransformer such that its applied after a method selector is done with the filtering logic of pruning the *in-eligible* methods? Please advise.

 

Thomas,

 

I would be curious to understand why you feel that its problematic for your AnnotationTransformer implementation to get access to all methods (even the ones which will be filtered out and not executed)?

 

I am not sure if it’s the intended behavior or not. Perhaps Cedric/Julien can add more context around it.

 

I currently don’t see any negative impact because of this behavior (Except for an additional execution time, because TestNG has to spend time on applying the transformer on all methods). Maybe you could help elaborate your specific issue on why this is problematic for you.

 

 

 

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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Thomas H

unread,
Jun 14, 2017, 10:58:56 AM6/14/17
to testng-users
Hi,

I have two reasons,
In my transformer I create a report that states which tests that were disabled and which will run. We use this report to feedback to other systems. We use this report as the output when we do a "dry run".

One of the criteria we annotate our tests with is the required test equipment. Some of which are shared resources. One idea was to reserve the equipment if available, and otherwise disable the test. But we don't want to reserve equipment if the test is not going to run. If we wait until later then we don't have the option to disable the test.
Maybe I could use IMethodInterceptor instead.

This is all part of a large continuous integration environment running in automated test labs.

/Thomas

Krishnan Mahadevan

unread,
Jun 14, 2017, 11:44:19 AM6/14/17
to testng...@googlegroups.com

Thomas,

 

I think you might want to consider using IMethodInterceptor (as you also pointed out) instead of the IAnnotationTransformer.

 

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/

 

From: <testng...@googlegroups.com> on behalf of Thomas H <nose...@gmail.com>


Reply-To: <testng...@googlegroups.com>
Date: Wednesday, June 14, 2017 at 8:28 PM
To: testng-users <testng...@googlegroups.com>

--

Reply all
Reply to author
Forward
0 new messages