File tree Expand file tree Collapse file tree
allure-junit-platform/src
main/java/io/qameta/allure/junitplatform
test/java/io/qameta/allure/junitplatform Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ public class AllureJunitPlatform implements TestExecutionListener {
100100 public static final String EVENT_STOP = "stop" ;
101101 public static final String EVENT_FAILURE = "failure" ;
102102
103+ public static final String JUNIT_PLATFORM_UNIQUE_ID = "junit.platform.uniqueid" ;
104+
103105 private static final String STDOUT = "stdout" ;
104106 private static final String STDERR = "stderr" ;
105107 private static final String TEXT_PLAIN = "text/plain" ;
@@ -373,6 +375,8 @@ private void startTestCase(final TestIdentifier testIdentifier) {
373375
374376 result .getLabels ().addAll (getProvidedLabels ());
375377
378+ result .getLabels ().add (getJUnitPlatformUniqueId (testIdentifier ));
379+
376380 testClass .map (AnnotationUtils ::getLabels ).ifPresent (result .getLabels ()::addAll );
377381 testMethod .map (AnnotationUtils ::getLabels ).ifPresent (result .getLabels ()::addAll );
378382
@@ -510,6 +514,13 @@ private List<Label> getSourceLabels(final TestSource source) {
510514 return Collections .emptyList ();
511515 }
512516
517+ private Label getJUnitPlatformUniqueId (final TestIdentifier testIdentifier ) {
518+ final Label label = new Label ();
519+ label .setName (JUNIT_PLATFORM_UNIQUE_ID );
520+ label .setValue (testIdentifier .getUniqueId ());
521+ return label ;
522+ }
523+
513524 private static class Uuids {
514525
515526 private final Map <TestIdentifier , String > storage = new ConcurrentHashMap <>();
Original file line number Diff line number Diff line change 2626import io .qameta .allure .junitplatform .features .DisabledTests ;
2727import io .qameta .allure .junitplatform .features .DynamicTests ;
2828import io .qameta .allure .junitplatform .features .FailedTests ;
29+ import io .qameta .allure .junitplatform .features .JupiterUniqueIdTest ;
2930import io .qameta .allure .junitplatform .features .MarkerAnnotationSupport ;
3031import io .qameta .allure .junitplatform .features .OneTest ;
3132import io .qameta .allure .junitplatform .features .OwnerTest ;
7071import java .util .Optional ;
7172import java .util .stream .Collectors ;
7273
74+ import static io .qameta .allure .junitplatform .AllureJunitPlatform .JUNIT_PLATFORM_UNIQUE_ID ;
7375import static io .qameta .allure .junitplatform .AllureJunitPlatformTestUtils .runClasses ;
7476import static io .qameta .allure .junitplatform .features .TaggedTests .CLASS_TAG ;
7577import static io .qameta .allure .junitplatform .features .TaggedTests .METHOD_TAG ;
@@ -759,4 +761,16 @@ void shouldSupportAllureIdAnnotations() {
759761
760762 }
761763
764+ @ AllureFeatures .Base
765+ @ Test
766+ void shouldPopulateTestCaseId () {
767+ final AllureResults results = runClasses (JupiterUniqueIdTest .class );
768+ final List <TestResult > testResults = results .getTestResults ();
769+ assertThat (testResults )
770+ .flatExtracting (TestResult ::getLabels )
771+ .filteredOn ("name" , JUNIT_PLATFORM_UNIQUE_ID )
772+ .extracting (Label ::getValue )
773+ .first ()
774+ .isEqualTo ("[engine:junit-jupiter]/[class:io.qameta.allure.junitplatform.features.JupiterUniqueIdTest]/[method:jupiterTest()]" );
775+ }
762776}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2019 Qameta Software OÜ
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package io .qameta .allure .junitplatform .features ;
17+
18+ import org .junit .jupiter .api .Test ;
19+
20+ /**
21+ * @author naresha (Naresha K)
22+ */
23+ public class JupiterUniqueIdTest {
24+
25+ @ Test
26+ void jupiterTest () {
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments