cucumber / godog

Cucumber for golang
MIT License
2.22k stars 250 forks source link

Genrating HTML reports #103

Closed rawlingsj closed 6 years ago

rawlingsj commented 6 years ago

Is there a way to generate HTML reports? I'm trying to figure out where the lines are drawn between godog / gherkin and cucumber. I've got a couple of basic godog tests but ideally I'd like to generate a report / html in a release pipeline which we can then host somewhere to describe the working features via the living documentation.

Are there any pointers of how I can generate a HTML report? I'd be happy to contribute an example back if I can get something working.

I'm wondering if I need to change the format, using the example:

    status := godog.RunWithOptions("godogs", func(s *godog.Suite) {
        FeatureContext(s)
    }, godog.Options{
        Format:    "progress",
        Paths:     []string{"features"},
        Randomize: time.Now().UTC().UnixNano(), // randomize scenario execution order
    })

Should changing progress to cucumber help as I didn't seem to see anything different. Also there's a gherkin.go which I'm not sure about. I'm pretty sure I'm missing a some basic understanding so any help / pointers would be great.

l3pp4rd commented 6 years ago

Hi, the formats supported are listed in godog -h. currently there is no html format. In cucumber team there is a progress going forward in implementing formatters for all cucumber implementations, it starts from gherkin which is now able to produce an event stream, which later may be consumed by an all in one formatter, which may produce many types of output including html, but the work is still in progress and may not be there soon. godog is a part of cucumber and later may be moved to the cucumber organization.

For now, I godog does not support html format, so you have two options, either wait for a while (maybe few months), or implement the temporary html formatter, see the fmt_junit.go for example.

Gherkin in godog is bundled in gherkin package, it uses version 3 at this moment, the gherkin.go file is just a minor func to support backward compatibility. Later when this all in one formatter will be available, godog will migrate to use gherkin v4 or higher.

rawlingsj commented 6 years ago

Thanks @l3pp4rd for the great explanation. I was looking at ginkgo and godog, this project I found easier to get going with and am looking for a project to both use and recommend to users of a OSS developer platform I'm involved with.

Waiting a few months or so for a html format sounds totally fine and we can start gaining the benefits of BDD / testing using godog till then. Hopefully we'll be able to help contribute too.

Did you want to close this issue or leave it open to track the html format work?

l3pp4rd commented 6 years ago

we can leave it open as a reminder ;)

myie-fnorton commented 6 years ago

A little late, but you can now generate HTML reports like https://rawgit.com/myie/cucumber-html-reporter/master/data/report.html, using https://github.com/myie/cucumber-html-reporter - just up, all feedback welcome.

rawlingsj commented 6 years ago

That's awesome! It's also perfect timing for us and we should be able to give it a whirl this week.

/cc @jstrachan

Dogild commented 6 years ago

@myie-fnorton Thanks for this, I'll look to it asap

l3pp4rd commented 6 years ago

nice, thanks guys, will need to reference it in the readme ;)

myie-fnorton commented 6 years ago

Glad the timing works @rawlingsj - let me know how it goes!

pjcalvohf commented 5 years ago

Hi, I am able to export the json file using something like this: go test > report.json. But this also adds some extra lines of the test execution that are breaking the report generator.

How can I generate a proper results.json file to later consume it with the cucumber-html-report?

l3pp4rd commented 5 years ago

Hi, godog runner configured from go test can be configured with a different io.Writer for the output it produces, so you can generate godog.json file for example. When you run your tests. You can even make a multi writer to write output to both file and stdout

harikumarrr commented 2 years ago

Hi, generate a godog test result json for cucumber-html-report godog --format=cucumber > cucumber.json

waytocypress commented 1 year ago

https://github.com/cucumber/godog/issues/103#issuecomment-492168132 Hi can you kindly suggest io.Writer? https://github.com/cucumber/godog/issues/103#issuecomment-363512823 The json which is getting generated is not in proper format. Do you have any solution for that?

harikamankala commented 1 year ago

Hi, godog runner configured from go test can be configured with a different io.Writer for the output it produces, so you can generate godog.json file for example. When you run your tests. You can even make a multi writer to write output to both file and stdout

Hi, Can you give me an example on how to use multi writer. Basically I need a html report along with running scenarios in parallel. I understand that scenarios can be run in parallel when format is 'progress'. Is it possible to generate html report while having concurrent scenarios?

waytocypress commented 1 year ago

for each _test.go file pass format at cucumber and unique file name for json file, store those json files at one location. Then you can generate html report using multiple html reporter or cucumber html reporter. Apart from that you can use gocure report(check cucumber official website for link). Lastly you can use allure reports, they are little tricky to configure but if you are following the folder structure which is mentioned on official godog github repo, you can configure allure reports easily