Giter VIP home page Giter VIP logo

goc-1's Introduction

goc

Go Report Card Build Release codecov GoDoc

中文页 |

goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing code coverage collection and accurate testing.

Enjoy, Have Fun! Demo

Installation

Download the latest version from Github Releases page.

Goc supports both GOPATH project and Go Modules project with Go 1.11+. However, for developing goc, you need to install Go 1.13+.

Examples

You can use goc tool in many scenarios.

Code Coverage Collection for Your Golang System Tests

Goc can collect code coverages at runtime for your long-run golang applications. To do that, normally just need three steps:

  1. use goc server to start a service registry center:
    ➜  simple-go-server git:(master) ✗ goc server
    
  2. use goc build to build the target service, and run the generated binary. Here let's take the simple-go-server project as example:
    ➜  simple-go-server git:(master) ✗ goc build .
    ... // omit logs
    ➜  simple-go-server git:(master) ✗ ./simple-go-server  
    
  3. use goc profile to get the code coverage profile of the started simple server above:
    ➜  simple-go-server git:(master) ✗ goc profile
    mode: atomic
    enricofoltran/simple-go-server/main.go:30.13,48.33 13 1
    enricofoltran/simple-go-server/main.go:48.33,50.3 1 0
    enricofoltran/simple-go-server/main.go:52.2,65.12 5 1
    enricofoltran/simple-go-server/main.go:65.12,74.46 7 1
    enricofoltran/simple-go-server/main.go:74.46,76.4 1 0
    ...   
    

Show Code Coverage Change at Runtime in Vscode

We provide a vscode extension - Goc Coverage which can show highlighted covered source code at runtime.

Extension

Tips

  1. To understand the execution details of goc tool, you can use the --debug flag. Also we appreciate if you can provide such logs when submitting a bug to us.

  2. By default, the covered service will listen a random port in order to communicate with the goc server. This may not be suitable in docker or kubernetes environment since the port must be exposed explicitly in order to be accessible by others in such environment. For this kind of scenario, you can use --agentport flag to specify a fixed port when calling goc build or goc install.

  3. To use a remote goc server, you can use --center flag to compile the target service with goc build or goc install command.

  4. The coverage data is stored on each covered service side, so if one service needs to restart during test, this service's coverage data will be lost. For this case, you can use following steps to handle:

    1. Before the service restarts, collect coverage with goc profile -o a.cov
    2. After service restarted and test finished, collect coverage again with goc profile -o b.cov
    3. Merge two coverage profiles together: goc merge a.cov b.cov -o merge.cov

RoadMap

  • Support code coverage collection for system testing.
  • Support code coverage counters clear for the services under test at runtime.
  • Support develop mode towards accurate testing.
  • Support code coverage diff based on Pull Request.
  • Optimize the performance costed by code coverage counters.

Contributing

We welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc.

Thanks to all contributors!!

License

Goc is released under the Apache 2.0 license. See LICENSE.txt

Join goc WeChat Group

WeChat

goc-1's People

Contributors

carlji avatar dependabot[bot] avatar e06084 avatar gavwu avatar longbai avatar lyyyuna avatar memoryliu avatar qiniu-bot avatar tongjingran avatar vieira-zj 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.