Skip to content

Commit e80a5dc

Browse files
committed
Added . Closes #418
1 parent 60bf05b commit e80a5dc

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

History.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [Git master](https://github.com/cucumber/cucumber-jvm/compare/v1.1.1...master)
22

3+
* [JUnit] Added `@Cucumber.Options.dotcucumber`, allowing metadata to be written from JUnit. Useful for code completion. ([#418](https://github.com/cucumber/cucumber-jvm/issues/418 Aslak Hellesøy)
34
* [Core] Embedded data fails to display in HTML reports due to invalid string passed from HTMLFormatter ([#412](https://github.com/cucumber/cucumber-jvm/issues/412) Aslak Hellesøy)
45
* [Scala] Downgrade to scala 2.9.2 - we'll only use stable versions from now on. (Aslak Hellesøy)
56
* [Scala] Passing Scenario reference in Before and After hooks ([#431](https://github.com/cucumber/cucumber-jvm/pull/431) Anshul Bajpai)

junit/src/main/java/cucumber/api/junit/Cucumber.java

+2
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,7 @@ private void addChildren(List<CucumberFeature> cucumberFeatures) throws Initiali
139139
* @return a list of patterns
140140
*/
141141
String[] name() default {};
142+
143+
String dotcucumber() default "";
142144
}
143145
}

junit/src/main/java/cucumber/runtime/junit/RuntimeOptionsFactory.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.List;
1010

1111
public class RuntimeOptionsFactory {
12-
private Class clazz;
12+
private final Class clazz;
1313

1414
public RuntimeOptionsFactory(Class clazz) {
1515
this.clazz = clazz;
@@ -21,18 +21,28 @@ public RuntimeOptions create() {
2121

2222
addDryRun(options, args);
2323
addMonochrome(options, args);
24-
addGlue(options, clazz, args);
24+
addGlue(options, args, clazz);
2525
addTags(options, args);
2626
addFormats(options, args);
27-
addFeatures(options, clazz, args);
27+
addFeatures(options, args, clazz);
2828
addStrict(options, args);
2929
addName(options, args);
30+
addDotCucumber(options, args);
3031

3132
RuntimeOptions runtimeOptions = new RuntimeOptions(System.getProperties(), args.toArray(new String[args.size()]));
3233

3334
return runtimeOptions;
3435
}
3536

37+
private void addDotCucumber(Cucumber.Options options, List<String> args) {
38+
if (options != null) {
39+
if (!options.dotcucumber().isEmpty()) {
40+
args.add("--dotcucumber");
41+
args.add(options.dotcucumber());
42+
}
43+
}
44+
}
45+
3646
private void addName(Cucumber.Options options, List<String> args) {
3747
if (options != null) {
3848
if (options.name().length != 0) {
@@ -70,7 +80,7 @@ private boolean runningInEnvironmentWithoutAnsiSupport() {
7080
return intelliJidea;
7181
}
7282

73-
private void addGlue(Cucumber.Options options, Class clazz, List<String> args) {
83+
private void addGlue(Cucumber.Options options, List<String> args, Class clazz) {
7484
if (options != null && options.glue().length != 0) {
7585
for (String glue : options.glue()) {
7686
args.add("--glue");
@@ -103,7 +113,7 @@ private void addFormats(Cucumber.Options options, List<String> args) {
103113
}
104114
}
105115

106-
private void addFeatures(Cucumber.Options options, Class clazz, List<String> args) {
116+
private void addFeatures(Cucumber.Options options, List<String> args, Class clazz) {
107117
if (options != null && options.features().length != 0) {
108118
Collections.addAll(args, options.features());
109119
} else {

junit/src/test/java/cucumber/runtime/junit/RuntimeOptionsFactoryTest.java

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cucumber.runtime.RuntimeOptions;
55
import org.junit.Test;
66

7+
import java.io.File;
78
import java.util.Iterator;
89
import java.util.List;
910
import java.util.regex.Pattern;
@@ -56,6 +57,13 @@ public void create_with_multiple_names() throws Exception {
5657
assertEquals("name2", getRegexpPattern(iterator.next()));
5758
}
5859

60+
@Test
61+
public void create_with_dotcucumber() {
62+
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(DotCucumber.class);
63+
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
64+
assertEquals(new File("somewhere/.cucumber"), runtimeOptions.dotCucumber);
65+
}
66+
5967
private String getRegexpPattern(Object pattern) {
6068
return ((Pattern) pattern).pattern();
6169
}
@@ -90,6 +98,11 @@ static class NoName {
9098
// empty
9199
}
92100

101+
@Cucumber.Options(dotcucumber = "somewhere/.cucumber")
102+
static class DotCucumber {
103+
// empty
104+
}
105+
93106
static class WithoutOptions {
94107
// empty
95108
}

0 commit comments

Comments
 (0)