Data Provider Parallelism : Programatically

23 views
Skip to first unread message

Musaffir lp

unread,
Oct 5, 2017, 4:13:33 AM10/5/17
to testng-users
Hello,

We have the wonderfurl @DataProvider feature which can be set with the attribute parallell=true to acheive the parallel execution of different data supllied
ex:


  @DataProvider(name = "parallelDataProvider", parallel=true)
   public Object[][] parallelDataProvider(Method testMethod) 
   {

       // some code
  }

Instead of, I hardocde this attribute like this .... can I pass it programatically ?
Why I am looking for this : beacuse I want my data provider to behave differently....i don't want it to supply the data in parallel always to the test methods.. i should be able to easily modify its behaviour...
and at the same time I do not want to come back here and update the attribute of the data provider method based on my need ...it should be able to change at run time ...


Thanks & Warm Regards
Musaffir



⇜Krishnan Mahadevan⇝

unread,
Oct 5, 2017, 4:19:02 AM10/5/17
to testng...@googlegroups.com
The following steps should help you with your use-case.
  • Build an implementation of org.testng.IAnnotationTransformer2
  • Plugin your transformation logic within org.testng.IAnnotationTransformer2#transform(org.testng.annotations.IDataProviderAnnotation, java.lang.reflect.Method)
  • Wire in this listener using the <listeners> tag or using Service loaders.

That should suffice.


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+unsubscribe@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.

Musaffir lp

unread,
Oct 5, 2017, 5:15:20 AM10/5/17
to testng-users
Thank you Krishnan
I already have a listener class which implements -  org.testng.internal.annotations.IAnnotationTransformer , where I was delibrately looking for this option....
Now I will look in to - org.testng.IAnnotationTransformer2
Thakns again


~ Musaffir
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages