- Sign up to Travis CI with your Github account.
- Click the green Activate button, and select the repositories you want to use with Travis CI.
- Add a
.travis.yml
file with the following content to your repository to tell Travis CI what to do:
language: java
jdk:
- oraclejdk8
- commit and push your changes to the github repo.
- New build will be triggered
- To measure code coverage we will use JaCoCo gradle plugin
- Add following lines to
build.gradle
file:
apply plugin: "jacoco"
<...>
jacoco {
toolVersion = "0.8.1"
}
jacocoTestReport {
reports {
xml.enabled=true
}
}
- Add script step to the
.travis.yml
file:
- gradle test jacocoTestReport
- commit these changes. If some of unit tests fail the build becomes red
Track code coverage and code quality using Code climate
- Sign up to Code climate with your Github account.
- Activate "Free for open source" account
- Add Github repository
- To analyze your code with each commit on Code Climate navigate to
Pero Settings
->Test Coverage
-> CopyTEST_REPORTED_ID
key - Add following lines to your
.travis.yml
file:
env:
global:
- CC_TEST_REPORTER_ID=<your_test_reporter_id>
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- gradle test jacocoTestReport
- JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage ./build/reports/jacoco/test/jacocoTestReport.xml --input-type jacoco
- ./cc-test-reporter upload-coverage -r $CC_TEST_REPORTER_ID
- If no mistakes your next build will trigger code coverage analysis on Code climate