Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/naver/cover-checker

Check your pull request code coverage
https://github.com/naver/cover-checker

cobertura code-coverage jacoco java

Last synced: about 2 months ago
JSON representation

Check your pull request code coverage

Awesome Lists containing this project

README

        

# Coverage Checker [![Build Status](https://travis-ci.org/naver/cover-checker.svg?branch=master)](https://travis-ci.org/naver/cover-checker)

CoverChecker provides a test coverage for new added lines of code.
If you create new pull request, CoverChecker would give feedback regarding how much of the new lines your test code has covered.

Good Test code makes people find bug more efficiently before service release and prevents service from being disabled.
To check the test code quality, most of developers refer the code coverage status as an important index.
This is why most of them spend their resources to update their test code to achieve more code coverage whenever they add new lines of code.
However, it has been hard to check and improve the code coverage as there are lots of old legacy codes which is not within the scope of the current test code.

> [Spring REST doc](https://spring.io/projects/spring-restdocs) is one of spring component. it makes api document from test code.

CoverChecker provides a feature to check the code coverage for new added code, not a whole code.
It will reduce the pressure to cover the whole and help you to achieve more coverage steadly and efficiently.
Makes your code more durable!

# CoverChecker do...

![example](doc/example.png)

- Find new code line from pull request
- Get test coverage each file from coverage report
- Combine information and check test code cover new code line
- Write report on pull request
- CoverChecker will fail when coverage doesn't satisfy your goal

# Run with jenkins

1. Install jdk 8 on your ci
2. Build CoverChecker
3. Fix your project to generate test coverage report(CoverChecker only Jacoco or Cobertura)
4. Execute CoverChecker in you build job

# How to build

Use maven wrapper

```sh
./gradlew clean build jar
```

then maven would make jar `cover-checker-console/build/libs/cover-checker-${version}-all.jar`

# Create access token

Create an [access token](https://github.com/settings/tokens/new?scopes=repo&description=cover-checker)

# Execute with parameter

```sh
java -jar cover-checker-console/build/libs/cover-checker-${version}-all.jar \
--cover ${coverageReportPath} \
[--cover ${otherCoverageReportPath}] \
--github-token ${githubAccessToken} \
--repo ${githubRepositoryPath} \
--threshold ${coverageThreshold} \
--github-url ${githubHost} \
--pr ${pullrequestNo} \
[-type (jacoco | cobertura)]
```

Note that both the `--cover` and `-type` parameters can be specified multiple times and are associated positionally.

For example, if you have two coverage reports in different formats, you can specify them like this:

```sh
java -jar cover-checker-console/build/libs/cover-checker-${version}-all.jar \
-type jacoco --cover jacoco.xml \
-type cobertura --cover cobertura.xml \
... # other parameters
```

### Parameter

```sh
usage: coverchecker.jar -c [-d ] [-dt ] [-ft ] [-g ]
[-p ] [-r ] -t [-type ] [-u ]
-c,--cover coverage report paths(absolute recommend), coverage
report path can take multiple paths for multi-module
project
-d,--diff diff file path(absolute recommend)
-dt,--diff-type diff type (github | file)
-ft,--file-threshold coverage report type (jacoco | cobertura) default is
jacoco
-g,--github-token github oauth token
-p,--pr github pr number
-r,--repo github repo
-t,--threshold coverage pass threshold
-type coverage report type (jacoco | cobertura) default is
jacoco
-u,--github-url The url when you working on github enterprise url.
default is api.github.com
```

## License

```
Copyright 2018 NAVER Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```