Skip to content

Commit 4e0b4a4

Browse files
authored
add support for recursive meta annotations (via #359)
1 parent c659614 commit 4e0b4a4

File tree

10 files changed

+380
-237
lines changed

10 files changed

+380
-237
lines changed

allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/**
5151
* Scenario labels and links builder.
5252
*/
53-
@SuppressWarnings({"CyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.NcssCount"})
53+
@SuppressWarnings({"CyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.NcssCount", "MultipleStringLiterals"})
5454
class LabelBuilder {
5555
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
5656
private static final String COMPOSITE_TAG_DELIMITER = "=";

allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureFeatures.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package io.qameta.allure.test;
1717

18-
import io.qameta.allure.LabelAnnotation;
18+
import io.qameta.allure.Feature;
1919

2020
import java.lang.annotation.Documented;
2121
import java.lang.annotation.ElementType;
@@ -24,8 +24,6 @@
2424
import java.lang.annotation.RetentionPolicy;
2525
import java.lang.annotation.Target;
2626

27-
import static io.qameta.allure.util.ResultsUtils.FEATURE_LABEL_NAME;
28-
2927
/**
3028
* @author charlie (Dmitry Baev).
3129
*/
@@ -37,191 +35,191 @@
3735
@Inherited
3836
@Retention(RetentionPolicy.RUNTIME)
3937
@Target({ElementType.METHOD, ElementType.TYPE})
40-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Basic framework support")
38+
@Feature("Basic framework support")
4139
@interface Base {
4240
}
4341

4442
@Documented
4543
@Inherited
4644
@Retention(RetentionPolicy.RUNTIME)
4745
@Target({ElementType.METHOD, ElementType.TYPE})
48-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Parallel test execution support")
46+
@Feature("Parallel test execution support")
4947
@interface Parallel {
5048
}
5149

5250
@Documented
5351
@Inherited
5452
@Retention(RetentionPolicy.RUNTIME)
5553
@Target({ElementType.METHOD, ElementType.TYPE})
56-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Full name")
54+
@Feature("Full name")
5755
@interface FullName {
5856
}
5957

6058
@Documented
6159
@Inherited
6260
@Retention(RetentionPolicy.RUNTIME)
6361
@Target({ElementType.METHOD, ElementType.TYPE})
64-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Display name")
62+
@Feature("Display name")
6563
@interface DisplayName {
6664
}
6765

6866
@Documented
6967
@Inherited
7068
@Retention(RetentionPolicy.RUNTIME)
7169
@Target({ElementType.METHOD, ElementType.TYPE})
72-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Descriptions")
70+
@Feature("Descriptions")
7371
@interface Descriptions {
7472
}
7573

7674
@Documented
7775
@Inherited
7876
@Retention(RetentionPolicy.RUNTIME)
7977
@Target({ElementType.METHOD, ElementType.TYPE})
80-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timings")
78+
@Feature("Timings")
8179
@interface Timings {
8280
}
8381

8482
@Documented
8583
@Inherited
8684
@Retention(RetentionPolicy.RUNTIME)
8785
@Target({ElementType.METHOD, ElementType.TYPE})
88-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Steps")
86+
@Feature("Steps")
8987
@interface Steps {
9088
}
9189

9290
@Documented
9391
@Inherited
9492
@Retention(RetentionPolicy.RUNTIME)
9593
@Target({ElementType.METHOD, ElementType.TYPE})
96-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Attachments")
94+
@Feature("Attachments")
9795
@interface Attachments {
9896
}
9997

10098
@Documented
10199
@Inherited
102100
@Retention(RetentionPolicy.RUNTIME)
103101
@Target({ElementType.METHOD, ElementType.TYPE})
104-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Parameters")
102+
@Feature("Parameters")
105103
@interface Parameters {
106104
}
107105

108106
@Documented
109107
@Inherited
110108
@Retention(RetentionPolicy.RUNTIME)
111109
@Target({ElementType.METHOD, ElementType.TYPE})
112-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Fixtures")
110+
@Feature("Fixtures")
113111
@interface Fixtures {
114112
}
115113

116114
@Documented
117115
@Inherited
118116
@Retention(RetentionPolicy.RUNTIME)
119117
@Target({ElementType.METHOD, ElementType.TYPE})
120-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Links")
118+
@Feature("Links")
121119
@interface Links {
122120
}
123121

124122
@Documented
125123
@Inherited
126124
@Retention(RetentionPolicy.RUNTIME)
127125
@Target({ElementType.METHOD, ElementType.TYPE})
128-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Marker annotations")
126+
@Feature("Marker annotations")
129127
@interface MarkerAnnotations {
130128
}
131129

132130
@Documented
133131
@Inherited
134132
@Retention(RetentionPolicy.RUNTIME)
135133
@Target({ElementType.METHOD, ElementType.TYPE})
136-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Failed tests")
134+
@Feature("Failed tests")
137135
@interface FailedTests {
138136
}
139137

140138
@Documented
141139
@Inherited
142140
@Retention(RetentionPolicy.RUNTIME)
143141
@Target({ElementType.METHOD, ElementType.TYPE})
144-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Broken tests")
142+
@Feature("Broken tests")
145143
@interface BrokenTests {
146144
}
147145

148146
@Documented
149147
@Inherited
150148
@Retention(RetentionPolicy.RUNTIME)
151149
@Target({ElementType.METHOD, ElementType.TYPE})
152-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Passed tests")
150+
@Feature("Passed tests")
153151
@interface PassedTests {
154152
}
155153

156154
@Documented
157155
@Inherited
158156
@Retention(RetentionPolicy.RUNTIME)
159157
@Target({ElementType.METHOD, ElementType.TYPE})
160-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Skipped tests")
158+
@Feature("Skipped tests")
161159
@interface SkippedTests {
162160
}
163161

164162
@Documented
165163
@Inherited
166164
@Retention(RetentionPolicy.RUNTIME)
167165
@Target({ElementType.METHOD, ElementType.TYPE})
168-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Ignored tests")
166+
@Feature("Ignored tests")
169167
@interface IgnoredTests {
170168
}
171169

172170
@Documented
173171
@Inherited
174172
@Retention(RetentionPolicy.RUNTIME)
175173
@Target({ElementType.METHOD, ElementType.TYPE})
176-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Not implemented tests")
174+
@Feature("Not implemented tests")
177175
@interface NotImplementedTests {
178176
}
179177

180178
@Documented
181179
@Inherited
182180
@Retention(RetentionPolicy.RUNTIME)
183181
@Target({ElementType.METHOD, ElementType.TYPE})
184-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "History")
182+
@Feature("History")
185183
@interface History {
186184
}
187185

188186
@Documented
189187
@Inherited
190188
@Retention(RetentionPolicy.RUNTIME)
191189
@Target({ElementType.METHOD, ElementType.TYPE})
192-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Retries")
190+
@Feature("Retries")
193191
@interface Retries {
194192
}
195193

196194
@Documented
197195
@Inherited
198196
@Retention(RetentionPolicy.RUNTIME)
199197
@Target({ElementType.METHOD, ElementType.TYPE})
200-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Stages")
198+
@Feature("Stages")
201199
@interface Stages {
202200
}
203201

204202
@Documented
205203
@Inherited
206204
@Retention(RetentionPolicy.RUNTIME)
207205
@Target({ElementType.METHOD, ElementType.TYPE})
208-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Trees")
206+
@Feature("Trees")
209207
@interface Trees {
210208
}
211209

212210
@Documented
213211
@Inherited
214212
@Retention(RetentionPolicy.RUNTIME)
215213
@Target({ElementType.METHOD, ElementType.TYPE})
216-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timeline")
214+
@Feature("Timeline")
217215
@interface Timeline {
218216
}
219217

220218
@Documented
221219
@Inherited
222220
@Retention(RetentionPolicy.RUNTIME)
223221
@Target({ElementType.METHOD, ElementType.TYPE})
224-
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timeline")
222+
@Feature("Timeline")
225223
@interface Severity {
226224
}
227225
}

allure-java-commons/src/main/java/io/qameta/allure/Issue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525

26+
import static io.qameta.allure.util.ResultsUtils.ISSUE_LINK_TYPE;
27+
2628
/**
2729
* Used to link tests with issues.
2830
*/
2931
@Documented
3032
@Inherited
3133
@Retention(RetentionPolicy.RUNTIME)
3234
@Target({ElementType.METHOD, ElementType.TYPE})
35+
@LinkAnnotation(type = ISSUE_LINK_TYPE)
3336
@Repeatable(Issues.class)
3437
public @interface Issue {
3538

allure-java-commons/src/main/java/io/qameta/allure/Link.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
@Inherited
3939
@Retention(RetentionPolicy.RUNTIME)
4040
@Target({ElementType.METHOD, ElementType.TYPE})
41+
@LinkAnnotation
4142
@Repeatable(Links.class)
4243
public @interface Link {
4344

allure-java-commons/src/main/java/io/qameta/allure/LinkAnnotation.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.lang.annotation.Documented;
1919
import java.lang.annotation.ElementType;
2020
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Repeatable;
2122
import java.lang.annotation.Retention;
2223
import java.lang.annotation.RetentionPolicy;
2324
import java.lang.annotation.Target;
@@ -36,20 +37,31 @@
3637
@Inherited
3738
@Retention(RetentionPolicy.RUNTIME)
3839
@Target({ElementType.ANNOTATION_TYPE})
40+
@Repeatable(LinkAnnotations.class)
3941
public @interface LinkAnnotation {
4042

43+
String DEFAULT_VALUE = "$$$$$$$$__value__$$$$$$$$";
44+
4145
/**
4246
* The value of link. In not specified will take value from <code>value()</code>
4347
* method of target annotation.
4448
*
4549
* @return the value of the link to add.
4650
*/
47-
String value() default "";
51+
String value() default DEFAULT_VALUE;
4852

4953
/**
5054
* This type is used for create an icon for link. Also there is few reserved types such as issue and tms.
5155
*
5256
* @return the link type.
5357
*/
5458
String type() default CUSTOM_LINK_TYPE;
59+
60+
/**
61+
* Url for link. By default will search for system property `allure.link.{type}.pattern`, and use it
62+
* to generate url.
63+
*
64+
* @return the link url.
65+
*/
66+
String url() default "";
5567
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* Wrapper annotation for {@link LinkAnnotation}.
27+
*/
28+
@Documented
29+
@Inherited
30+
@Retention(RetentionPolicy.RUNTIME)
31+
@Target({ElementType.ANNOTATION_TYPE})
32+
public @interface LinkAnnotations {
33+
34+
LinkAnnotation[] value();
35+
36+
}

allure-java-commons/src/main/java/io/qameta/allure/TmsLink.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525

26+
import static io.qameta.allure.util.ResultsUtils.TMS_LINK_TYPE;
27+
2628
/**
2729
* Used to link tests with test cases in external test management system.
2830
*/
2931
@Documented
3032
@Inherited
3133
@Retention(RetentionPolicy.RUNTIME)
3234
@Target({ElementType.METHOD, ElementType.TYPE})
35+
@LinkAnnotation(type = TMS_LINK_TYPE)
3336
@Repeatable(TmsLinks.class)
3437
public @interface TmsLink {
3538

0 commit comments

Comments
 (0)