I am Currently working on a big java project, which needs to be managed in bigger & better ways. It is using SVN , Hudson , Sonar. After multiple checkins in a day , a nightly Hudson build is run , which also runs sonar , hence giving the new stats ( of code coverage , complexities etc ). But these numbers are not very useful as of now as they tell situation / figures after checkin.
The practical situation is that , with every checkin the code covergae is decreasing. Now we want to bench mark the figures at present level. Lets say Code Coverage presently is at 45% What we want is the next checkin should be allowed if and only if it increases code code coverage % else not.
My question is how this can be done ??
I did some research around , came to know of two possible ways
- Use SVN Hooks
- Use Continuous Build servers like Hudson
For 1st Option found link / tutorial : Can i run a script when i commit to subversion?
The following two links seems to suggest 2nd option is better ( as it has much less checkin time)
- Sonar integration with SVN
- How can I guarantee all unit tests pass before committing?
- Also suggests using "Continuous Integration Game"
Questions
- As i haven't worked on configuring hudson ( just used it as a normal user to initiate build ) what i dont understand from above two links is that... Sonar will run AFTER checkin is done, so how will it stop user to checkin if some test case failed ? or is my understanding incorrect ?? or it will send an email to all developers indicating stats before and after checkin ? or it will send email only if test case fails ??
- My use case is little different... before deciding to commit or not i want to check the new coverage % (including the present checkin changes ) and old coverage % ( before checkin changes ) and allow only if the new > old ... how can i do this using hudson+sonar ?? any code/config examples ??
- Or my use case is not possible by using Hudson ... and SVN hook is the only option for me ?? if yes any code example on how to do this
Let me know if i need to clarify my question further