File tree Expand file tree Collapse file tree
main/java/io/qameta/allure/testng
java/io/qameta/allure/testng Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -649,13 +649,19 @@ public void onConfigurationSkip(final ITestResult itr) {
649649 public void beforeDataProviderExecution (final IDataProviderMethod dataProviderMethod ,
650650 final ITestNGMethod method ,
651651 final ITestContext iTestContext ) {
652- final String containerUuid = UUID .randomUUID ().toString ();
653- getLifecycle ().startTestContainer (
654- new TestResultContainer ()
655- .setUuid (containerUuid )
656- .setName (method .getMethodName ())
652+ currentExecutable .remove ();
653+ final String containerUuid = dataProviderContainerUuidStorage .computeIfAbsent (
654+ method ,
655+ key -> {
656+ final String uuid = UUID .randomUUID ().toString ();
657+ getLifecycle ().startTestContainer (
658+ new TestResultContainer ()
659+ .setUuid (uuid )
660+ .setName (method .getMethodName ())
661+ );
662+ return uuid ;
663+ }
657664 );
658- dataProviderContainerUuidStorage .put (method , containerUuid );
659665
660666 final String uuid = currentExecutable .get ();
661667 final FixtureResult result = new FixtureResult ()
Original file line number Diff line number Diff line change @@ -1545,6 +1545,20 @@ public void shouldProcessFailedDataProviderInSetup() {
15451545 .contains (Tuple .tuple ("dataProvider" , Status .BROKEN ));
15461546 }
15471547
1548+ @ AllureFeatures .Fixtures
1549+ @ Test (description = "Should process flaky data provider in setup" )
1550+ public void shouldProcessFlakyDataProvider () {
1551+ final AllureResults results = runTestNgSuites ("suites/flaky-data-provider.xml" );
1552+
1553+ assertThat (results .getTestResultContainers ())
1554+ .flatExtracting (TestResultContainer ::getBefores )
1555+ .extracting (FixtureResult ::getName , FixtureResult ::getStatus )
1556+ .containsSubsequence (
1557+ Tuple .tuple ("provide" , Status .BROKEN ),
1558+ Tuple .tuple ("provide" , Status .PASSED )
1559+ );
1560+ }
1561+
15481562 private Integer getOrderParameter (final TestResult result ) {
15491563 return result .getParameters ().stream ()
15501564 .filter (p -> p .getName ().equals ("order" ))
Original file line number Diff line number Diff line change 1+ package io .qameta .allure .testng .samples ;
2+
3+ import org .testng .IDataProviderMethod ;
4+ import org .testng .IRetryDataProvider ;
5+ import org .testng .ITestResult ;
6+ import org .testng .annotations .BeforeClass ;
7+ import org .testng .annotations .DataProvider ;
8+ import org .testng .annotations .Test ;
9+
10+ import java .util .concurrent .atomic .AtomicInteger ;
11+
12+ public class FlakyDataProvider {
13+
14+ private static final AtomicInteger COUNTER = new AtomicInteger (0 );
15+
16+ @ BeforeClass
17+ public void reset () {
18+ COUNTER .set (0 );
19+ }
20+
21+ public static class Retry implements IRetryDataProvider {
22+ @ Override
23+ public boolean retry (IDataProviderMethod method ) {
24+ return COUNTER .incrementAndGet () < 2 ;
25+ }
26+ }
27+
28+ @ DataProvider (retryUsing = Retry .class )
29+ public Object [][] provide () {
30+ if (COUNTER .get () == 0 ) {
31+ throw new RuntimeException ("Simulated DataProvider Failure" );
32+ }
33+ return new Object [][]{{"data" }};
34+ }
35+
36+ @ Test (dataProvider = "provide" )
37+ public void test (String s ) {
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
2+ <suite name =" Flaky Data Provider Suite" verbose =" 1" parallel =" false" thread-count =" 1" >
3+ <test name =" Flaky Data Provider Test" >
4+ <classes >
5+ <class name =" io.qameta.allure.testng.samples.FlakyDataProvider" />
6+ </classes >
7+ </test >
8+ </suite >
You can’t perform that action at this time.
0 commit comments