goc/README.md

70 lines
3.7 KiB
Markdown
Raw Normal View History

# goc
[![Go Report Card](https://goreportcard.com/badge/github.com/qiniu/goc)](https://goreportcard.com/report/github.com/qiniu/goc)
![](https://github.com/qiniu/goc/workflows/ut-check/badge.svg)
![](https://github.com/qiniu/goc/workflows/style-check/badge.svg)
![](https://github.com/qiniu/goc/workflows/e2e%20test/badge.svg)
2020-07-03 12:19:55 +00:00
![Build Release](https://github.com/qiniu/goc/workflows/Build%20Release/badge.svg)
2020-05-23 08:44:13 +00:00
[![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)
2020-05-24 08:41:41 +00:00
goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarioslike system testing code coverage collection and
2020-05-22 11:08:38 +00:00
accurate testing.
2020-06-19 06:18:52 +00:00
Enjoy, Have Fun!
2020-06-16 15:27:44 +00:00
![Demo](docs/images/intro.gif)
2020-05-09 10:22:33 +00:00
## Installation
2020-05-22 11:08:38 +00:00
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
2020-05-24 08:36:17 +00:00
Goc can collect code coverages at runtime for your long-run golang applications. To do that, normally just need three steps:
2020-05-22 11:08:38 +00:00
1. use `goc server` to start a service registry center:
```
➜ simple-go-server git:(master) ✗ goc server
```
2020-05-24 08:41:41 +00:00
2. use `goc build` to build the target service, and run the generated binary. Here let's take the [simple-go-server](https://github.com/CarlJi/simple-go-server) project as example:
2020-05-22 11:08:38 +00:00
```
➜ 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
...
```
2020-07-03 16:01:10 +00:00
## 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](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose) or [kubernetes](https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service) 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 specific 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.
2020-05-22 11:08:38 +00:00
## RoadMap
- [x] Support code coverage collection for system testing.
- [x] Support code coverage counters clear for the services under test at runtime.
2020-05-22 11:08:38 +00:00
- [ ] Support develop mode towards accurate testing.
2020-05-24 08:41:41 +00:00
- [ ] Support code coverage diff based on Pull Request.
2020-05-22 11:08:38 +00:00
- [ ] Optimize the performance costed by code coverage counters.
## Contributing
2020-06-19 06:18:52 +00:00
We welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc.
Thanks to all [contributors](https://github.com/qiniu/goc/graphs/contributors)!!
2020-05-22 11:08:38 +00:00
## License
2020-05-24 08:53:58 +00:00
Goc is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/qiniu/goc/blob/master/LICENSE)