Open GoogleCodeExporter opened 9 years ago
Darn, I was googling all over to find out how to do this in TestNG. Looks like
the
answer is "you can't, not without hacking it together, anyway".
To reiterate, I want one row of data from the dataprovider to be passed to
several
tests before moving on to the next row of data.
Original comment by jeffrey.m.weiss@gmail.com
on 21 Jan 2009 at 8:50
Original comment by nalin.ma...@gmail.com
on 20 Jun 2010 at 2:32
I want something similar to this, but not quite the same. Now that there are
parallel dataProviders and dynamic run order, what I want is not many steps
away.
If method A and method B both use the same dataProvider, and method B depends
on method A, I want (optional) finer granularity in that dependency.
Right now: First method A works through all of the items in the dataProvider,
then method B starts pulling from the dataProvider.
What I want: As method A finishes processing items in the dataProvider, those
items become available for method B to process. Methods A and B can optionally
run in parallel with themselves. In a way, this still fulfills the dependency
promise, because for any given item, method A is executed & finished before
method B starts. All of this would require dynamic analysis of which items are
ready at any given point, since there are no guarantees about the relative
speeds of items going through method A.
Original comment by OrigamiM...@gmail.com
on 3 Jul 2010 at 10:35
I met the same problem. I am not able to solve it also. I added dataProvider
annotation to Class level but then you don't have any options to get data
inside methods.
Original comment by roman.ra...@gmail.com
on 31 Aug 2012 at 2:00
I am facing the similar issue and need to use the shared dataprovider across
different tests as stated in the original post above. Please let me know if any
of you found a solution to this ?
Original comment by shikss.a...@gmail.com
on 28 Nov 2012 at 7:49
> Please let me know if any of you found a solution to this
My project (Bio-Formats) works around the issue using the test factory approach
illustrated in SharedDataProviderTest2 above.
It is vital that each test class instance not actually initialize its big data
structures until its "before-class" annotated method is called (rather than
doing so in the constructor). And then when the "after-class" annotated method
is called, the big data structures must be cleared.
As long as you don't have any method dependencies, TestNG calls all test
methods of a particular instance before moving on to the next instance, as
illustrated in SharedDataProviderTest2.
Relevant Bio-Formats classes illustrating the technique:
* https://github.com/openmicroscopy/bioformats/tree/master/components/test-suite/src/loci/tests/testng/FormatReaderTest.java
* https://github.com/openmicroscopy/bioformats/tree/master/components/test-suite/src/loci/tests/testng/FormatReaderTestFactory.java
This approach does limit you to 2^31-1 test class instances, which has been
more than sufficient for my use cases.
As noted above, the execution order may be an implementation detail of TestNG,
but in practice it works.
Original comment by ctrueden...@gmail.com
on 28 Nov 2012 at 6:29
Is there a workaround?
I need to be able to run multiple tests sharing the same data provider...
Original comment by Nivea...@gmail.com
on 6 Mar 2014 at 8:27
Plus, my tests have to run in a particular order...
Original comment by Nivea...@gmail.com
on 6 Mar 2014 at 8:29
Original issue reported on code.google.com by
ctrueden...@gmail.com
on 27 Feb 2008 at 8:33Attachments: