|
29 | 29 | import io.qameta.allure.junitplatform.features.FailedTests; |
30 | 30 | import io.qameta.allure.junitplatform.features.JupiterUniqueIdTest; |
31 | 31 | import io.qameta.allure.junitplatform.features.MarkerAnnotationSupport; |
| 32 | +import io.qameta.allure.junitplatform.features.NestedDisplayNameTests; |
32 | 33 | import io.qameta.allure.junitplatform.features.NestedTests; |
33 | 34 | import io.qameta.allure.junitplatform.features.OneTest; |
34 | 35 | import io.qameta.allure.junitplatform.features.OwnerTest; |
|
97 | 98 | import static io.qameta.allure.util.ResultsUtils.HOST_LABEL_NAME; |
98 | 99 | import static io.qameta.allure.util.ResultsUtils.OWNER_LABEL_NAME; |
99 | 100 | import static io.qameta.allure.util.ResultsUtils.PACKAGE_LABEL_NAME; |
| 101 | +import static io.qameta.allure.util.ResultsUtils.PARENT_SUITE_LABEL_NAME; |
100 | 102 | import static io.qameta.allure.util.ResultsUtils.SEVERITY_LABEL_NAME; |
101 | 103 | import static io.qameta.allure.util.ResultsUtils.STORY_LABEL_NAME; |
| 104 | +import static io.qameta.allure.util.ResultsUtils.SUB_SUITE_LABEL_NAME; |
102 | 105 | import static io.qameta.allure.util.ResultsUtils.SUITE_LABEL_NAME; |
103 | 106 | import static io.qameta.allure.util.ResultsUtils.TAG_LABEL_NAME; |
104 | 107 | import static io.qameta.allure.util.ResultsUtils.TEST_CLASS_LABEL_NAME; |
@@ -984,6 +987,126 @@ void shouldSupportNestedClasses() { |
984 | 987 | ); |
985 | 988 | } |
986 | 989 |
|
| 990 | + @AllureFeatures.Trees |
| 991 | + @Issue("1234") |
| 992 | + @Issue("1052") |
| 993 | + @Test |
| 994 | + void shouldSetSuiteLabelsForNestedClasses() { |
| 995 | + final AllureResults allureResults = runClasses(NestedTests.class); |
| 996 | + |
| 997 | + assertThat(allureResults.getTestResults()) |
| 998 | + .filteredOn("name", "story1Test()") |
| 999 | + .flatExtracting(TestResult::getLabels) |
| 1000 | + .extracting(Label::getName, Label::getValue) |
| 1001 | + .contains( |
| 1002 | + tuple(PARENT_SUITE_LABEL_NAME, "io.qameta.allure.junitplatform.features.NestedTests"), |
| 1003 | + tuple(SUITE_LABEL_NAME, "Feature2"), |
| 1004 | + tuple(SUB_SUITE_LABEL_NAME, "Story1") |
| 1005 | + ); |
| 1006 | + |
| 1007 | + assertThat(allureResults.getTestResults()) |
| 1008 | + .filteredOn("name", "feature1Test()") |
| 1009 | + .flatExtracting(TestResult::getLabels) |
| 1010 | + .extracting(Label::getName, Label::getValue) |
| 1011 | + .contains( |
| 1012 | + tuple(PARENT_SUITE_LABEL_NAME, "io.qameta.allure.junitplatform.features.NestedTests"), |
| 1013 | + tuple(SUITE_LABEL_NAME, "Feature1") |
| 1014 | + ); |
| 1015 | + |
| 1016 | + assertThat(allureResults.getTestResults()) |
| 1017 | + .filteredOn("name", "feature1Test()") |
| 1018 | + .flatExtracting(TestResult::getLabels) |
| 1019 | + .extracting(Label::getName) |
| 1020 | + .doesNotContain(SUB_SUITE_LABEL_NAME); |
| 1021 | + |
| 1022 | + assertThat(allureResults.getTestResults()) |
| 1023 | + .filteredOn("name", "parentTest()") |
| 1024 | + .flatExtracting(TestResult::getLabels) |
| 1025 | + .extracting(Label::getName, Label::getValue) |
| 1026 | + .contains(tuple(SUITE_LABEL_NAME, "io.qameta.allure.junitplatform.features.NestedTests")); |
| 1027 | + |
| 1028 | + assertThat(allureResults.getTestResults()) |
| 1029 | + .filteredOn("name", "parentTest()") |
| 1030 | + .flatExtracting(TestResult::getLabels) |
| 1031 | + .extracting(Label::getName) |
| 1032 | + .doesNotContain(PARENT_SUITE_LABEL_NAME, SUB_SUITE_LABEL_NAME); |
| 1033 | + } |
| 1034 | + |
| 1035 | + @AllureFeatures.Trees |
| 1036 | + @Issue("1234") |
| 1037 | + @Issue("1052") |
| 1038 | + @Test |
| 1039 | + void shouldUseDisplayNamesForNestedClassesSuiteStructure() { |
| 1040 | + final AllureResults allureResults = runClasses(NestedDisplayNameTests.class); |
| 1041 | + |
| 1042 | + assertThat(allureResults.getTestResults()) |
| 1043 | + .extracting(TestResult::getName) |
| 1044 | + .containsExactlyInAnyOrder( |
| 1045 | + "can be created with the dao", |
| 1046 | + "it must be saved to the dao", |
| 1047 | + "it can be fetched from the dao", |
| 1048 | + "it cannot be deleted by wrong id", |
| 1049 | + "it is still present" |
| 1050 | + ); |
| 1051 | + |
| 1052 | + assertThat(allureResults.getTestResults()) |
| 1053 | + .filteredOn("name", "can be created with the dao") |
| 1054 | + .flatExtracting(TestResult::getLabels) |
| 1055 | + .extracting(Label::getName, Label::getValue) |
| 1056 | + .contains(tuple(SUITE_LABEL_NAME, "A customer object")); |
| 1057 | + |
| 1058 | + assertThat(allureResults.getTestResults()) |
| 1059 | + .filteredOn("name", "can be created with the dao") |
| 1060 | + .flatExtracting(TestResult::getLabels) |
| 1061 | + .extracting(Label::getName) |
| 1062 | + .doesNotContain(PARENT_SUITE_LABEL_NAME, SUB_SUITE_LABEL_NAME); |
| 1063 | + |
| 1064 | + assertThat(allureResults.getTestResults()) |
| 1065 | + .filteredOn("name", "it must be saved to the dao") |
| 1066 | + .flatExtracting(TestResult::getLabels) |
| 1067 | + .extracting(Label::getName, Label::getValue) |
| 1068 | + .contains( |
| 1069 | + tuple(PARENT_SUITE_LABEL_NAME, "A customer object"), |
| 1070 | + tuple(SUITE_LABEL_NAME, "when created") |
| 1071 | + ); |
| 1072 | + |
| 1073 | + assertThat(allureResults.getTestResults()) |
| 1074 | + .filteredOn("name", "it must be saved to the dao") |
| 1075 | + .flatExtracting(TestResult::getLabels) |
| 1076 | + .extracting(Label::getName) |
| 1077 | + .doesNotContain(SUB_SUITE_LABEL_NAME); |
| 1078 | + |
| 1079 | + assertThat(allureResults.getTestResults()) |
| 1080 | + .filteredOn("name", "it can be fetched from the dao") |
| 1081 | + .flatExtracting(TestResult::getLabels) |
| 1082 | + .extracting(Label::getName, Label::getValue) |
| 1083 | + .contains( |
| 1084 | + tuple(PARENT_SUITE_LABEL_NAME, "A customer object"), |
| 1085 | + tuple(SUITE_LABEL_NAME, "when created"), |
| 1086 | + tuple(SUB_SUITE_LABEL_NAME, "after saving a customer") |
| 1087 | + ); |
| 1088 | + |
| 1089 | + assertThat(allureResults.getTestResults()) |
| 1090 | + .filteredOn("name", "it is still present") |
| 1091 | + .flatExtracting(TestResult::getLabels) |
| 1092 | + .extracting(Label::getName, Label::getValue) |
| 1093 | + .contains( |
| 1094 | + tuple(PARENT_SUITE_LABEL_NAME, "A customer object"), |
| 1095 | + tuple(SUITE_LABEL_NAME, "when created"), |
| 1096 | + tuple(SUB_SUITE_LABEL_NAME, "after saving a customer > and reloading the dao") |
| 1097 | + ); |
| 1098 | + |
| 1099 | + assertThat(allureResults.getTestResults()) |
| 1100 | + .filteredOn("name", "it can be fetched from the dao") |
| 1101 | + .extracting(TestResult::getTitlePath) |
| 1102 | + .containsExactly( |
| 1103 | + Arrays.asList( |
| 1104 | + "io", "qameta", "allure", "junitplatform", "features", |
| 1105 | + "A customer object", "when created", "after saving a customer" |
| 1106 | + ) |
| 1107 | + ); |
| 1108 | + } |
| 1109 | + |
987 | 1110 | @AllureFeatures.Attachments |
988 | 1111 | @SuppressWarnings("OptionalGetWithoutIsPresent") |
989 | 1112 | @Test |
|
0 commit comments