For encouraging them I proposed to give a free evening for the member that wrote the most tests in a month time. It was fun and developers, despite their lack of experience unit testing, created a good bunch of tests. Maybe the test weren't that good or complete, but at lest we had tests that could run every night.
The bad part: I did the test count by hand. It was only once a month and didn't expent much time anyway.
But fear not! If you are interested in doing something similiar I present you.
The Junit Award Maven Plugin
This plug in scans the entire src/test/java fould of your project searching for the @author tag of javadoc, getting the author name and increasing the count for it. Kind of simple for now.
The @author tag must be enclosed in a javadoc block like:
* @author ggefaell
* @author Guillermo Gefaell
It generates a simple html page with the results.
For now i'm still seeing how to get the plugin to be avaliable at a repository, but you can follow this steps for runing it on your project.
- Add the plugin to your project's pom.
- Run mvn junitward:awards on your project.
- The results are generated in the folder /target/junitaward/junitAwards.html
The next improvements are:
Get it to a repository so no forking-installing.Done Add a "Since Date" parameter so you can know how many tests have been written in a time span. Improving @author scan so it counts only in functions noted with @Test.
Edit: Chanded groupId to com.github.konum and deployed it to central repository, so you can use it directly as a plugin in your project's pom.
Edit 2: Version 1.2 is out! Thre optional parameters for the plugin for count tests since a given date, change tests root folder and a date pattern option. See more at githubproject. https://github.com/konum/JUnit-Awards