GithubHelp home page GithubHelp logo

coolalexhuang / gocov-html Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matm/gocov-html

0.0 1.0 0.0 1.49 MB

Produces HTML output from gocov, a coverage testing tool for the Go programming language

License: MIT License

Go 54.20% CSS 6.08% Makefile 8.61% HTML 30.67% Dockerfile 0.44%

gocov-html's Introduction

Gocov HTML export

This is a simple helper tool for generating HTML output from axw/gocov.

gocov-html has support for themes, you might want to have a look at the screenshots.

Installation

Binaries for most amd64 systems are built for every release. Please just grab a binary version of the latest release.

You can also build it from source. In this case, a working Go 1.11+ compiler is required:

$ go install github.com/matm/gocov-html/cmd/gocov-html@latest

A Dockerfile is also provided.

Features Matrix

Feature CLI Flag Version
Use custom CSS file -s <filename> 1.0.0
Show program version -v 1.1.1
Write CSS of default theme to stdout -d 1.2.0
Embbed custom CSS into final HTML document - 1.2.0
List available themes -lt 1.2.0
Render with a specific theme -t <theme> 1.2.0
New kit theme -t kit 1.3.0
Put lower coverage functions on top -r 1.3.1

Usage

$ gocov-html -h
Usage of ./gocov-html:
  -d    output CSS of default theme
  -lt
        list available themes
  -s string
        path to custom CSS file
  -t string
        theme to use for rendering (default "golang")
  -v    show program version

gocov-html can read a JSON file or read from standard input:

$ gocov test strings | gocov-html > strings.html
ok      strings 0.700s  coverage: 98.1% of statements

Several packages can be tested at once and added to a single report. Let's test the fmt, math and io packages:

$ gocov test fmt math io | gocov-html > report.html
ok      fmt     0.045s  coverage: 95.2% of statements
ok      math    0.006s  coverage: 83.6% of statements
ok      io      0.024s  coverage: 88.2% of statements

In this case, the generated report will have an overview section with stats per package along with the global coverage percentage. This section may be rendered depending on the theme used. The golang (default) theme displays it.

The generated HTML content comes along with a default embedded CSS. However a custom stylesheet can be used with the -s flag:

$ gocov test net/http | gocov-html -s mystyle.css > http.html

As of version 1.2,

  • A -d flag is available to write the defaut stylesheet to the standard output. This is provided for convenience and easy editing:
    $ gocov-html -d > newstyle.css
    ... edit newstyle.css ...
    $ gocov test strings | gocov-html -s newstyle.css > http.html
    
  • The content of the stylesheet given to -s is embedded into the final HTML document
  • Theming capabilities are available (to go further than just using a CSS file) through the use of Go templates.
    • Use the -lt flag to list available themes:
      $ gocov-html -lt
      golang     -- original golang theme (default)
      
    • Generate a report using a specific theme with -t:
      $ gocov test io | gocov-html -t golang > io.html
      

gocov-html's People

Contributors

matm avatar mschoch avatar popbones avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.