Code Monkey home page Code Monkey logo

go-opine's Introduction

go-opine

Go Report Card Build Status GoDoc NetflixOSS Lifecycle GitHub

Project Overview

go-opine is an opiniated way to run go test ./... -race and generate percent total of lines covered by tests. By default go-opine exits successfully if at least 50% code has test coverage, but this can be configured. go-opine tries to ignore and skip code that was generated by tools when calculating test coverage (e.g minimock mocks). go-opine also supports outputting test coverage reports in various formats, such as junit & cobertura.

Getting Started

Run go-opine test to test for code coverage in the root of a go project. For example, running in this repo produces the following output:

~/go-opine $
go-opine test
?       indeed.com/gophers/go-opine     [no test files]
ok      indeed.com/gophers/go-opine/internal/run        0.039s
ok      indeed.com/gophers/go-opine/internal/printing   0.019s
ok      indeed.com/gophers/go-opine/internal/coverage   0.317s
ok      indeed.com/gophers/go-opine/internal/junit      0.364s
ok      indeed.com/gophers/go-opine/internal/gotest     1.572s
ok      indeed.com/gophers/go-opine/internal/cmd        3.132s
Test coverage sufficient (85.4% >= 50.0%)

To generate a go coverage report, junit report, or corbertura report, see the usage info:

$ go-opine help test
test [-min-coverage <percent>] [-junit <path>] [-xmlcov <path>] [-coverprofile <path>]:
  Run Go tests in an opinionated way.
  -coverprofile string
        write Go coverprofile coverage
  -junit string
        write JUnit XML test results
  -min-coverage float
        minimum code test coverage to enforce (default 50)
  -xmlcov string
        write Cobertura XML coverage

Configuring minimum code coverage

By default go-opine requires 50% code coverage. This may not be adequate for every project, but Indeed has found it to be a good minimum. For projects that want to enforce different test coverage requirements, set the -min-coverage flag to the coverage percentage desired, between 0 and 100.

For example, to enforce a 75% code coverage requirement:

go-opine test -min-coverage 75

To disable code coverage requirements entirely, set -min-coverage to 0.

go-opine is a Go tool

Since go-opine is typically a tool dependency (rather than a library dependency) you can use the "tools.go" approach described in gotools and go#25922 to declare the dependency.

If you are not using a tools.go you can go get go-opine and install it on your path.

How To Contribute

We welcome contributions! Feel free to help make go-opine better.

Process

  • Open an issue and describe the desired feature / bug fix before making changes. It's useful to get a second pair of eyes before investing development effort.
  • Make the change. If adding a new feature, remember to provide tests that demonstrate the new feature works, including any error paths. If contributing a bug fix, add tests that demonstrate the erroneous behavior is fixed.
  • Open a pull request. Automated CI tests will run. If the tests fail, please make changes to fix the behavior, and repeat until the tests pass.
  • Once everything looks good, one of the indeedeng members will review the PR and provide feedback.

Maintainers

The oss.indeed.com/go/go-opine module is maintained by Indeed Engineering.

While we are always busy helping people get jobs, we will try to respond to GitHub issues, pull requests, and questions within a couple of business days.

Code of Conduct

This project is governed by the Contributor Covenant v 1.4.1.

License

This project uses the Apache 2.0 license. (Update this and the LICENSE file if your project uses a different license.)

go-opine's People

Contributors

cnmcavoy avatar deadok22 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.