@@ -153,6 +153,10 @@ public class AllureTestNg implements
153153 * Store uuid for class test containers.
154154 */
155155 private final Map <ITestClass , String > classContainerUuidStorage = new ConcurrentHashMap <>();
156+ /**
157+ * Store uuid for data provider containers.
158+ */
159+ private final Map <ITestNGMethod , String > dataProviderContainerUuidStorage = new ConcurrentHashMap <>();
156160 private final ReadWriteLock lock = new ReentrantReadWriteLock ();
157161 private final AllureLifecycle lifecycle ;
158162 private final AllureTestNgTestFilter testFilter ;
@@ -283,6 +287,14 @@ public void onAfterClass(final ITestClass testClass) {
283287 getLifecycle ().stopTestContainer (uuid );
284288 getLifecycle ().writeTestContainer (uuid );
285289 });
290+ dataProviderContainerUuidStorage .entrySet ().removeIf (entry -> {
291+ if (entry .getKey ().getTestClass ().equals (testClass )) {
292+ getLifecycle ().stopTestContainer (entry .getValue ());
293+ getLifecycle ().writeTestContainer (entry .getValue ());
294+ return true ;
295+ }
296+ return false ;
297+ });
286298 }
287299
288300 @ Override
@@ -305,6 +317,10 @@ public void onTestStart(final ITestResult testResult) {
305317 .map (ITestResult ::getMethod )
306318 .map (ITestNGMethod ::getTestClass )
307319 .ifPresent (clazz -> addClassContainerChild (clazz , uuid ));
320+
321+ Optional .of (testResult )
322+ .map (ITestResult ::getMethod )
323+ .ifPresent (method -> addDataProviderContainerChild (method , uuid ));
308324 }
309325
310326 @ SuppressWarnings ("BooleanExpressionComplexity" )
@@ -633,7 +649,14 @@ public void onConfigurationSkip(final ITestResult itr) {
633649 public void beforeDataProviderExecution (final IDataProviderMethod dataProviderMethod ,
634650 final ITestNGMethod method ,
635651 final ITestContext iTestContext ) {
636- final ITestClass testClass = method .getTestClass ();
652+ final String containerUuid = UUID .randomUUID ().toString ();
653+ getLifecycle ().startTestContainer (
654+ new TestResultContainer ()
655+ .setUuid (containerUuid )
656+ .setName (method .getMethodName ())
657+ );
658+ dataProviderContainerUuidStorage .put (method , containerUuid );
659+
637660 final String uuid = currentExecutable .get ();
638661 final FixtureResult result = new FixtureResult ()
639662 .setName (dataProviderMethod .getMethod ().getName ())
@@ -646,39 +669,33 @@ public void beforeDataProviderExecution(final IDataProviderMethod dataProviderMe
646669 result ::setDescriptionHtml
647670 );
648671
649- getClassContainer (testClass ).ifPresent (parentUuid ->
650- getLifecycle ().startPrepareFixture (parentUuid , uuid , result )
651- );
672+ getLifecycle ().startPrepareFixture (containerUuid , uuid , result );
652673 }
653674
654675 @ Override
655676 public void afterDataProviderExecution (final IDataProviderMethod dataProviderMethod ,
656677 final ITestNGMethod method ,
657678 final ITestContext iTestContext ) {
658- final ITestClass testClass = method .getTestClass ();
659- getClassContainer (testClass ).ifPresent (parentUuid -> {
660- final String uuid = currentExecutable .get ();
661- getLifecycle ().updateFixture (uuid , result -> {
662- if (result .getStatus () == null ) {
663- result .setStatus (Status .PASSED );
664- }
665- });
666- getLifecycle ().stopFixture (uuid );
667- currentExecutable .remove ();
679+ final String uuid = currentExecutable .get ();
680+ getLifecycle ().updateFixture (uuid , result -> {
681+ if (result .getStatus () == null ) {
682+ result .setStatus (Status .PASSED );
683+ }
668684 });
685+ getLifecycle ().stopFixture (uuid );
686+ currentExecutable .remove ();
669687 }
670688
671689 @ Override
672690 public void onDataProviderFailure (final ITestNGMethod method ,
673691 final ITestContext ctx ,
674692 final RuntimeException t ) {
675- final ITestClass testClass = method .getTestClass ();
676- getClassContainer (testClass ).ifPresent (parentUuid -> {
677- final String uuid = currentExecutable .get ();
678- getLifecycle ().updateFixture (uuid , result -> result
679- .setStatus (getStatus (t ))
680- .setStatusDetails (getStatusDetails (t ).orElse (null )));
681- });
693+ final String uuid = currentExecutable .get ();
694+ getLifecycle ().updateFixture (uuid , result -> result
695+ .setStatus (getStatus (t ))
696+ .setStatusDetails (getStatusDetails (t ).orElse (null )));
697+ getLifecycle ().stopFixture (uuid );
698+ currentExecutable .remove ();
682699 }
683700
684701 protected String getHistoryId (final ITestNGMethod method , final List <Parameter > parameters ) {
@@ -882,6 +899,10 @@ private Consumer<TestResult> setStatus(final Status status, final StatusDetails
882899 };
883900 }
884901
902+ private void addDataProviderContainerChild (final ITestNGMethod method , final String childUuid ) {
903+ this .addChildToContainer (dataProviderContainerUuidStorage .get (method ), childUuid );
904+ }
905+
885906 private void addClassContainerChild (final ITestClass clazz , final String childUuid ) {
886907 this .addChildToContainer (classContainerUuidStorage .get (clazz ), childUuid );
887908 }
0 commit comments