DEV Community

Cover image for Using GOCURE to generate html reports in GO
Rodrigo Odhin
Rodrigo Odhin

Posted on

Using GOCURE to generate html reports in GO

Some months ago, I wanted to generate a modern html report from my selenoid json reports using Go. I tried to find something good for me already ready to use, but I didn't. So I've created the GOCURE.

GOCURE is a library written in pure Go providing the possibility to generate html reports from cucumber json reports.

 

Import

Is it possible to use gocure by importing in a project

import (
    "gitlab.com/rodrigoodhin/gocure/pkg/htmlreport"
)
Enter fullscreen mode Exit fullscreen mode

Generate html report file with charts

htmlreport.Generate("cucumber_report.json", "output/", true)
Enter fullscreen mode Exit fullscreen mode

Generate report html file without charts

htmlreport.Generate("cucumber_report.json", "output/", false)
Enter fullscreen mode Exit fullscreen mode

Generate report html text with charts

htmlReport, _ := htmlreport.Export("cucumber_report.json", true)
Enter fullscreen mode Exit fullscreen mode

Generate report html text without charts

htmlReport, _ := htmlreport.Export("cucumber_report.json", false)
Enter fullscreen mode Exit fullscreen mode

Build and Execute

If you don't want to import, you can build the project and execute

git clone git@gitlab.com:rodrigoodhin/gocure.git
cd gocure
go build gocure.go
Enter fullscreen mode Exit fullscreen mode

Usage of gocure

Example:
./gocure -j <CucumberJSONFile> -o <OutputFolder> -c

-j = Cucumber Json File. MANDATORY
-o = Output Folder
-c = Set if chart will be included
Enter fullscreen mode Exit fullscreen mode

Example:

./gocure -j /path/to/json/file.json
./gocure -j /path/to/json/file.json -o output/folder/
./gocure -j /path/to/json/file.json -o output/folder/ -c
Enter fullscreen mode Exit fullscreen mode

 

HTML Report Screenshot

Example of a html report generated with gocure

HTML Report Screenshot

 

Gitlab Repository

Top comments (0)