javacucumberbddcucumber-jvmatdd

Cucumber reports can't take more than one formatter?


For some reason my code will only run when using one formatter.

@RunWith(Cucumber.class)
@Cucumber.Options(features={"src/test/resources/cucumber"}, glue={"cucumber.com.zzz.yyy.steps"}, format={"html:target/test-reports"})
public class RunCucumberTest {

}

If I add another:

format={"pretty","html:target/test-reports"}

I get a IndexOutOfBoundsException:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:604)
    at java.util.ArrayList.get(ArrayList.java:382)
    at gherkin.formatter.PrettyFormatter.indentedLocation(PrettyFormatter.java:142)
    at gherkin.formatter.PrettyFormatter.printStep(PrettyFormatter.java:255)
    at gherkin.formatter.PrettyFormatter.match(PrettyFormatter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

If I add another:

format={"pretty","html:target/test-reports", "json:target/test-reports/cucumber.json"}

I get another IndexOutOfBoundsException this time = -1:

java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:371)
    at java.util.ArrayList.get(ArrayList.java:384)
    at gherkin.formatter.JSONFormatter.getFeatureElement(JSONFormatter.java:199)
    at gherkin.formatter.JSONFormatter.addHook(JSONFormatter.java:156)
    at gherkin.formatter.JSONFormatter.before(JSONFormatter.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at cucumber.runtime.Utils$1.call(Utils.java:44)
    at cucumber.runtime.Timeout.timeout(Timeout.java:12)
    at cucumber.runtime.Utils.invoke(Utils.java:40)
    at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:138)
    at com.sun.proxy.$Proxy12.before(Unknown Source)
    at cucumber.runtime.junit.JUnitReporter.before(JUnitReporter.java:129)
    at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:208)
    at cucumber.runtime.Runtime.runHooks(Runtime.java:185)
    at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:175)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:32)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:83)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:77)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:82)

Can anyone help me figure out what is going on!!!!?

Versions:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
    <optional>true</optional>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-jvm-deps</artifactId>
    <scope>test</scope>
     <version>1.0.3</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <scope>test</scope>
     <version>1.1.3</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <scope>test</scope>
    <version>1.1.3</version>
</dependency>

Solution

  • Added jvm dependency:

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>1.1.5</version>
        <type>pom</type>
    </dependency>
    

    And everything ran correctly.