Code Coverage Report25 January 2016 - time to read: 2min
Hello developer friends,
In this post I will explain how to generate code coverage via Travis-ci and Codecov.
Conditions for this tutorial:
Your project must be on github. Project must be written in java and maven configuration needed.
If you are not familiar with the technologies you can check out these links first:
- Sing in to travis-ci with github account.
- Sync your repositories by clicking Sync Account button in your profile page.
- Switch on the button next to your repository. Now Travis will try to build your repository when you make a commit.
- Sign in to codecov with your github account.
- Add your github repository. Now you can see your coverage report on the site after travis builds your repository.
Open your github repository on github.
Edit your pom.xml by adding jacoco plugin.
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.5.8.201207111220</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>
- Add .travis.yml file to your repository. And add following lines.
language: java sudo: false # faster builds before_install: - pip install --user codecov after_success: - codecov
After these configurations travis will try to build your project.
You can see your coverage report on codecov.io after successful build.
You can access to my example repository with this link: example-java
Have a nice coding day.