@@ -115,8 +115,18 @@ public class AllureJunitPlatform implements TestExecutionListener {
115115
116116 private final ThreadLocal <TestPlan > testPlanStorage = new InheritableThreadLocal <>();
117117
118- private final Uuids tests = new Uuids ();
119- private final Uuids containers = new Uuids ();
118+ private final ThreadLocal <Uuids > tests = new InheritableThreadLocal <Uuids >() {
119+ @ Override
120+ protected Uuids initialValue () {
121+ return new Uuids ();
122+ }
123+ };
124+ private final ThreadLocal <Uuids > containers = new InheritableThreadLocal <Uuids >() {
125+ @ Override
126+ protected Uuids initialValue () {
127+ return new Uuids ();
128+ }
129+ };
120130
121131 private final AllureLifecycle lifecycle ;
122132
@@ -135,11 +145,15 @@ public AllureLifecycle getLifecycle() {
135145 @ Override
136146 public void testPlanExecutionStarted (final TestPlan testPlan ) {
137147 testPlanStorage .set (testPlan );
148+ tests .set (new Uuids ());
149+ containers .set (new Uuids ());
138150 }
139151
140152 @ Override
141153 public void testPlanExecutionFinished (final TestPlan testPlan ) {
142154 testPlanStorage .remove ();
155+ tests .remove ();
156+ containers .remove ();
143157 }
144158
145159 @ Override
@@ -199,7 +213,7 @@ public void executionSkipped(final TestIdentifier testIdentifier,
199213 );
200214 }
201215
202- @ SuppressWarnings ({"ReturnCount" , "PMD.NcssCount" , "CyclomaticComplexity" })
216+ @ SuppressWarnings ({"ReturnCount" , "PMD.NcssCount" , "CyclomaticComplexity" })
203217 @ Override
204218 public void reportingEntryPublished (final TestIdentifier testIdentifier ,
205219 final ReportEntry entry ) {
@@ -270,7 +284,7 @@ private void processParameterEvent(final Map<String, String> keyValuePairs) {
270284 );
271285 }
272286
273- @ SuppressWarnings ({"ReturnCount" })
287+ @ SuppressWarnings ({"ReturnCount" })
274288 private void processFixtureEvent (final TestIdentifier testIdentifier ,
275289 final Map <String , String > keyValuePairs ) {
276290 final String type = keyValuePairs .get (ALLURE_FIXTURE );
@@ -283,7 +297,7 @@ private void processFixtureEvent(final TestIdentifier testIdentifier,
283297
284298 switch (event ) {
285299 case EVENT_START :
286- final Optional <String > maybeParent = containers . get (testIdentifier );
300+ final Optional <String > maybeParent = getContainer (testIdentifier );
287301 if (!maybeParent .isPresent ()) {
288302 return ;
289303 }
@@ -308,7 +322,7 @@ private void resetContext(final TestIdentifier testIdentifier) {
308322 // test case uuid to allure thread local storage
309323 Optional .of (testIdentifier )
310324 .filter (TestIdentifier ::isTest )
311- .flatMap (tests :: get )
325+ .flatMap (( TestIdentifier t ) -> getTest ( t ) )
312326 .ifPresent (Allure .getLifecycle ()::setCurrentTestCase );
313327 }
314328
@@ -333,7 +347,7 @@ protected Status getStatus(final Throwable throwable) {
333347 }
334348
335349 private void startTestContainer (final TestIdentifier testIdentifier ) {
336- final String uuid = containers . getOrCreate (testIdentifier );
350+ final String uuid = getOrCreateContainer (testIdentifier );
337351 final TestResultContainer result = new TestResultContainer ()
338352 .setUuid (uuid )
339353 .setName (testIdentifier .getDisplayName ());
@@ -342,7 +356,7 @@ private void startTestContainer(final TestIdentifier testIdentifier) {
342356 }
343357
344358 private void stopTestContainer (final TestIdentifier testIdentifier ) {
345- final Optional <String > maybeUuid = containers . get (testIdentifier );
359+ final Optional <String > maybeUuid = getContainer (testIdentifier );
346360 if (!maybeUuid .isPresent ()) {
347361 return ;
348362 }
@@ -353,14 +367,14 @@ private void stopTestContainer(final TestIdentifier testIdentifier) {
353367 .orElseGet (Collections ::emptySet )
354368 .stream ()
355369 .filter (TestIdentifier ::isTest )
356- .map (tests :: get )
370+ .map (this :: getTest )
357371 .filter (Optional ::isPresent )
358372 .map (Optional ::get )
359373 .distinct ()
360374 .collect (Collectors .toCollection (ArrayList ::new ));
361375
362376 if (testIdentifier .isTest ()) {
363- tests . get (testIdentifier ).ifPresent (children ::add );
377+ getTest (testIdentifier ).ifPresent (children ::add );
364378 }
365379
366380 getLifecycle ().updateTestContainer (uuid , container -> container .setChildren (children ));
@@ -421,7 +435,7 @@ private void stopFixture(final Map<String, String> keyValue) {
421435
422436 @ SuppressWarnings ("PMD.NcssCount" )
423437 private void startTestCase (final TestIdentifier testIdentifier ) {
424- final String uuid = tests . getOrCreate (testIdentifier );
438+ final String uuid = getOrCreateTest (testIdentifier );
425439
426440 final Optional <TestSource > testSource = testIdentifier .getSource ();
427441 final Optional <Method > testMethod = testSource
@@ -519,7 +533,7 @@ private void startTestCase(final TestIdentifier testIdentifier) {
519533 private void stopTestCase (final TestIdentifier testIdentifier ,
520534 final Status status ,
521535 final StatusDetails statusDetails ) {
522- final Optional <String > maybeUuid = tests . get (testIdentifier );
536+ final Optional <String > maybeUuid = getTest (testIdentifier );
523537 if (!maybeUuid .isPresent ()) {
524538 return ;
525539 }
@@ -614,6 +628,22 @@ private Label getJUnitPlatformUniqueId(final TestIdentifier testIdentifier) {
614628 return label ;
615629 }
616630
631+ private Optional <String > getContainer (final TestIdentifier testIdentifier ) {
632+ return containers .get ().get (testIdentifier );
633+ }
634+
635+ private String getOrCreateContainer (final TestIdentifier testIdentifier ) {
636+ return containers .get ().getOrCreate (testIdentifier );
637+ }
638+
639+ private Optional <String > getTest (final TestIdentifier testIdentifier ) {
640+ return tests .get ().get (testIdentifier );
641+ }
642+
643+ private String getOrCreateTest (final TestIdentifier testIdentifier ) {
644+ return tests .get ().getOrCreate (testIdentifier );
645+ }
646+
617647 private static class Uuids {
618648
619649 private final Map <TestIdentifier , String > storage = new ConcurrentHashMap <>();
0 commit comments