add example into README document

This commit is contained in:
jichangjun 2020-05-22 19:08:38 +08:00
parent 2178853f4c
commit a2fe20da97
2 changed files with 49 additions and 2 deletions

View File

@ -6,10 +6,56 @@
[![codecov](https://codecov.io/gh/qiniu/goc/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/goc)
[![GoDoc](https://godoc.org/github.com/qiniu/goc?status.svg)](https://godoc.org/github.com/qiniu/goc)
A Comprehensive Coverage Testing System for The Go Programming Language
goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scanrioslike system testing code coverage collecting and
accurate testing.
> **Note:**
>
> This readme and related documentation are Work in Progress.
## Installation
```go get github.com/qiniu/goc```
To install goc tool, you need to install Go first (**version 1.11+ is required**), then:
```go get -u github.com/qiniu/goc```
## Examples
You can use goc tool in many scenarios.
### Code Coverage Collection for your Golang System Tests
Goc can collect code coverages at run time 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 [simeple-go-server](https://github.com/CarlJi/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
...
```
Enjoy, Have Fun!
## RoadMap
- [x] Support code coverage collection for system testing.
- [ ] Support develop mode towards accurate testing.
- [ ] Support code coverage diff based on Pull Requst.
- [ ] Support code coverage counters clear for the services under test in runtime.
- [ ] 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.
## License
Goc is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/qiniu/goc/blob/master/LICENSE.txt)

1
go.sum
View File

@ -548,6 +548,7 @@ github.com/openzipkin/zipkin-go v0.2.0/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc=
github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=