4

I'm investigating using gradle and cucumber together, and found this lovely example in cucumber's github.

So, I cloned the repository and ran it myself. It failed, as it's configured to do, but I couldn't find the HTML or JSON report that it appears to be configured to output. I say appear because I'm brand new to cucumber, but this class would seem to indicate where it'll put it:

@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:build/cucumber-html-report", "json-pretty:build/cucumber-report.json"})
public class RunCukesTest {

}

However, it's not appearing in the build directory after running gradle cucumber.There's no cucumber-html-report directory, not is there a cucumber-report.json file. I'm running it with Java 7 and Gradle 1.6, if it matters.

Ideas? Is this a known issue with the Cucumber/Gradle integration?

Depressio
  • 1,329
  • 2
  • 20
  • 39

4 Answers4

3

The class name changed depending on the version of Cucumber you are using. It changed from json-pretty to json.

Robert
  • 5,278
  • 43
  • 65
  • 115
1

When running the 'cucumber' task on this example the generated cucumber report is located at 'build/cucumber-html-report/index.html'. Running the 'test' task fails as it seems that gradle has problems to create the test report for the cucumber created tests (file name contains spaces) I need to dig a bit into this to see how this can be fixed in gradle.

cheers,

René

Rene Groeschke
  • 27,999
  • 10
  • 69
  • 78
  • 1
    I am running `gradle cucumber`, but there is no report in build. That's the question: why? – Depressio Jul 26 '13 at 03:45
  • I can't reproduce this. when I run "gradle cucumber" I got the test report in the directory I mentioned – Rene Groeschke Jul 26 '13 at 13:05
  • Weird. I literally clone cucumber-jvm with git, go to the java-gradle example, and do gradle cucumber... build only has classes, dependency-cache, libs, and tmp inside of it. I've done this on two computers, too. Is there some sort of environment variable or something I need? – Depressio Jul 26 '13 at 13:41
  • 1
    sorry my fault. the report is generated when running "gradle test". I need to dig a bit deeper into it to figure out what's the problem here. maybe the cucumber guys can help out. – Rene Groeschke Jul 27 '13 at 02:26
  • OK, if you add `--format blah:blah/blah` (of course, with a valid format) to the args of the javaexec that runs `cucumber.api.cli.Main`, it reports OK without having to run `gradle test` (which has some weird issues). – Depressio Jul 29 '13 at 15:18
1

The cucumber-jvm-example doesn't do reporting using gradle cucumber, but does do it with gradle test. However, gradle test will have a couple issues, namely showing a "null" test of sorts.

A workaround to this, if need be, is to add the formats to the args of the javaexec that runs cucumber. For example, in build.gradle:

javaexec {
    main = "cucumber.api.cli.Main"
    classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
    args = ['--format', 'html:cucumber-html-report', '-f', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
}
Depressio
  • 1,329
  • 2
  • 20
  • 39
0

I had an error with that very same line (taken from this tutorial). In order to resolve, had to change the third parameter from "json-pretty" to just "pretty"

So this is my final code line: @CucumberOptions(format = {"pretty", "html:target/cucumber-html-report", "pretty:target/cucumber-report.json"})

BTW, @Cucumber.Options is deprecated, we should use CucumberOptions

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
eladleb
  • 2,616
  • 26
  • 21