File tree Expand file tree Collapse file tree 5 files changed +99
-13
lines changed
spock-core/src/main/java/spock/lang
spock-specs/src/test/groovy/org/spockframework Expand file tree Collapse file tree 5 files changed +99
-13
lines changed Original file line number Diff line number Diff line change @@ -490,14 +490,7 @@ To indicate that a feature or spec relates to one or more issues in an external
490
490
491
491
[source,groovy]
492
492
----
493
- @Issue("http://my.issues.org/FOO-1")
494
- class MySpec {
495
- @Issue("http://my.issues.org/FOO-2")
496
- def "Foo should do bar"() { ... }
497
-
498
- @Issue(["http://my.issues.org/FOO-3", "http://my.issues.org/FOO-4"])
499
- def "I have two related issues"() { ... }
500
- }
493
+ include::{sourcedir}/extension/IssueDocSpec.groovy[tag=example]
501
494
----
502
495
503
496
If you have a common prefix URL for all issues in a project, you can use the <<Spock Configuration File>> to set it up
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ include::include.adoc[]
14
14
15
15
- `@ConfineMetaClassChanges` is now repeatable
16
16
17
+ - `@Issue` is now repeatable
18
+
17
19
18
20
== 2.0-M3 (2020-06-11)
19
21
Original file line number Diff line number Diff line change 18
18
19
19
import org .spockframework .runtime .extension .ExtensionAnnotation ;
20
20
import org .spockframework .runtime .extension .builtin .IssueExtension ;
21
+ import org .spockframework .util .Beta ;
21
22
22
23
import java .lang .annotation .*;
23
24
30
31
@ Retention (RetentionPolicy .RUNTIME )
31
32
@ Target ({ElementType .TYPE , ElementType .METHOD })
32
33
@ ExtensionAnnotation (IssueExtension .class )
34
+ @ Repeatable (Issue .Container .class )
33
35
public @interface Issue {
34
36
/**
35
37
* The IDs of the issues that the annotated element relates to.
36
38
*
37
39
* @return the IDs of the issues that the annotated element relates to
38
40
*/
39
41
String [] value ();
42
+
43
+ /**
44
+ * @since 2.0
45
+ */
46
+ @ Beta
47
+ @ Retention (RetentionPolicy .RUNTIME )
48
+ @ Target ({ElementType .TYPE , ElementType .METHOD })
49
+ @interface Container {
50
+ Issue [] value ();
51
+ }
40
52
}
Original file line number Diff line number Diff line change
1
+ package org.spockframework.docs.extension
2
+
3
+ import spock.lang.Issue
4
+ import spock.lang.Specification
5
+
6
+ // tag::example[]
7
+ @Issue (" http://my.issues.org/FOO-1" )
8
+ class IssueDocSpec extends Specification {
9
+ @Issue (" http://my.issues.org/FOO-2" )
10
+ def " Foo should do bar" () {
11
+ expect : true
12
+ }
13
+
14
+ @Issue ([" http://my.issues.org/FOO-3" , " http://my.issues.org/FOO-4" ])
15
+ def " I have two related issues" () {
16
+ expect : true
17
+ }
18
+
19
+ @Issue ([" http://my.issues.org/FOO-5" , " http://my.issues.org/FOO-6" ])
20
+ @Issue (" http://my.issues.org/FOO-7" )
21
+ def " I have three related issues" () {
22
+ expect : true
23
+ }
24
+ }
25
+ // end::example[]
Original file line number Diff line number Diff line change @@ -61,11 +61,65 @@ class IssueExtension extends EmbeddedSpecification {
61
61
url == " http://my.issues.org/FOO-1"
62
62
}
63
63
with(tags[1 ]) {
64
- name == " FOO-2"
65
- key == " issue"
66
- value == " FOO-2"
67
- url == " http://my.issues.org/FOO-2"
68
- }
64
+ name == " FOO-2"
65
+ key == " issue"
66
+ value == " FOO-2"
67
+ url == " http://my.issues.org/FOO-2"
68
+ }
69
+ }
70
+
71
+ @Issue (" http://my.issues.org/FOO-1" )
72
+ @Issue (" http://my.issues.org/FOO-2" )
73
+ def " if multiple issue annotations are applied, all of them are converted to a tag" () {
74
+ def tags = specificationContext. currentFeature. tags
75
+
76
+ expect :
77
+ tags. size() == 2
78
+ with(tags[0 ]) {
79
+ name == " FOO-1"
80
+ key == " issue"
81
+ value == " FOO-1"
82
+ url == " http://my.issues.org/FOO-1"
83
+ }
84
+ with(tags[1 ]) {
85
+ name == " FOO-2"
86
+ key == " issue"
87
+ value == " FOO-2"
88
+ url == " http://my.issues.org/FOO-2"
89
+ }
90
+ }
91
+
92
+ @Issue ([" http://my.issues.org/FOO-1" , " http://my.issues.org/FOO-2" ])
93
+ @Issue ([" http://my.issues.org/FOO-3" , " http://my.issues.org/FOO-4" ])
94
+ def " if multiple issue annotations with multiple issues are applied, all of them are converted to a tag" () {
95
+ def tags = specificationContext. currentFeature. tags
96
+
97
+ expect :
98
+ tags. size() == 4
99
+ with(tags[0 ]) {
100
+ name == " FOO-1"
101
+ key == " issue"
102
+ value == " FOO-1"
103
+ url == " http://my.issues.org/FOO-1"
104
+ }
105
+ with(tags[1 ]) {
106
+ name == " FOO-2"
107
+ key == " issue"
108
+ value == " FOO-2"
109
+ url == " http://my.issues.org/FOO-2"
110
+ }
111
+ with(tags[2 ]) {
112
+ name == " FOO-3"
113
+ key == " issue"
114
+ value == " FOO-3"
115
+ url == " http://my.issues.org/FOO-3"
116
+ }
117
+ with(tags[3 ]) {
118
+ name == " FOO-4"
119
+ key == " issue"
120
+ value == " FOO-4"
121
+ url == " http://my.issues.org/FOO-4"
122
+ }
69
123
}
70
124
71
125
def " complains if @Issue is used on anything other than a spec or feature" () {
You can’t perform that action at this time.
0 commit comments