13
13
public class RuntimeOptionsFactory {
14
14
private final Class clazz ;
15
15
private final Class <? extends Annotation >[] annotationClasses ;
16
+ private boolean featuresSpecified = false ;
17
+ private boolean glueSpecified = false ;
18
+ private boolean formatSpecified = false ;
16
19
17
20
public RuntimeOptionsFactory (Class clazz , Class <? extends Annotation >[] annotationClasses ) {
18
21
this .clazz = clazz ;
@@ -39,11 +42,14 @@ private List<String> buildArgsFromOptions() {
39
42
addName (options , args );
40
43
addDotCucumber (options , args );
41
44
addSnippets (options , args );
45
+ addGlue (optionsArray , args );
46
+ addFeatures (optionsArray , args );
42
47
}
43
48
}
44
- addGlue (optionsArray , args , classWithOptions );
45
- addFeatures (optionsArray , args , classWithOptions );
46
49
}
50
+ addDefaultFeaturePathIfNoFeaturePathIsSpecified (args , clazz );
51
+ addDefaultGlueIfNoGlueIsSpecified (args , clazz );
52
+ addDefaultFormatIfNoFormatIsSpecified (args );
47
53
return args ;
48
54
}
49
55
@@ -92,37 +98,46 @@ private void addFormats(Annotation options, List<String> args) {
92
98
args .add ("--format" );
93
99
args .add (format );
94
100
}
95
- } else {
101
+ formatSpecified = true ;
102
+ }
103
+ }
104
+
105
+ private void addDefaultFormatIfNoFormatIsSpecified (List <String > args ) {
106
+ if (!formatSpecified ) {
96
107
args .add ("--format" );
97
108
args .add ("null" );
98
109
}
99
110
}
100
111
101
- private void addFeatures (Annotation [] optionsArray , List <String > args , Class clazz ) {
102
- boolean specified = false ;
112
+ private void addFeatures (Annotation [] optionsArray , List <String > args ) {
103
113
for (Annotation options : optionsArray ) {
104
114
if (options != null && this .<String []>invoke (options , "features" ).length != 0 ) {
105
115
Collections .addAll (args , this .<String []>invoke (options , "features" ));
106
- specified = true ;
116
+ featuresSpecified = true ;
107
117
}
108
118
}
109
- if (!specified ) {
119
+ }
120
+
121
+ private void addDefaultFeaturePathIfNoFeaturePathIsSpecified (List <String > args , Class clazz ) {
122
+ if (!featuresSpecified ) {
110
123
args .add (MultiLoader .CLASSPATH_SCHEME + packagePath (clazz ));
111
124
}
112
125
}
113
126
114
- private void addGlue (Annotation [] optionsArray , List <String > args , Class clazz ) {
115
- boolean specified = false ;
127
+ private void addGlue (Annotation [] optionsArray , List <String > args ) {
116
128
for (Annotation options : optionsArray ) {
117
129
if (options != null && this .<String []>invoke (options , "glue" ).length != 0 ) {
118
130
for (String glue : this .<String []>invoke (options , "glue" )) {
119
131
args .add ("--glue" );
120
132
args .add (glue );
121
133
}
122
- specified = true ;
134
+ glueSpecified = true ;
123
135
}
124
136
}
125
- if (!specified ) {
137
+ }
138
+
139
+ private void addDefaultGlueIfNoGlueIsSpecified (List <String > args , Class clazz ) {
140
+ if (!glueSpecified ) {
126
141
args .add ("--glue" );
127
142
args .add (MultiLoader .CLASSPATH_SCHEME + packagePath (clazz ));
128
143
}
0 commit comments