Testing - mvn clean test -Dtest=MyTest (runs a single test) you can use this for testing packages also - mvn clean surefire-report:report ( run unit test and builds a surefire reports in target site dir. )
Testing Code coverage - mvn clean cobertura:check ( run unit test and make sure we clear the check ) - mvn clean cobertura:cobertura
For a while i had mixed feelings about code coverage test and that has not changed but the number of lines in my projects has grown and we are under stress to deliver more features by the day I started to worry a bit about our test coverage of the code...
I have always used the cobertura-maven-plugin to generate reports of the code coverage but that is about it, ya cook look graphs that tell you how you are doing but never used it for more than that... This weekend is stated looking at my coverage and started to add checks to each project to make sure we can't build if we fail below a set % of code coverage.
That was good and bad... i played with a lot of the different settings that you can check and ended up using only total line rate (see blow) where the system make sure we run over % of the total lines in the project and if we don't hit the build fails...
A few things to note:
I was suppressed to learn that cobertura does not work well with static or enum classes and calls.
You should exclude any auto generated code from your coverage check
A new fill called cobertura.ser will show up on desk.. make sure you add it to the .cvsingore or source control ignore file since if that file is checked in it will break everything
Step 4:
I tent do run mvn test to gen the source and run the unit test with the genrated sources
NOTES:
- Don't check in autogen into source countral
After trial and error i learned not to check the auto gen code since you contal the changes to it by checked in the wsdl.
- Exclude autogen code from code covrage
using org.codehaus.mojo to do code covrage i tend to add the following plugin and exclude the auto gencode... so that the reports are clean
By adding the following plugins to your pom.xml you will be able to precompile your JSPs and have them included in your war file.
1. part is to include the jspc-mavne-plugin which will complile your jsp into java classess. Make sure to configure the java vesion for the jsp classes.
Every project I worked on needed a build system and most of the time it has been a big ugly ant build system which once written no one wants to own it or say they worked on it. Over the last few year i stared using maven at work. At that point of time Maven 2 was the new build system that should solve every build system nightmare. At first it was hard using maven, things that our old build system maven could not due out of the box. But over the years i learned to love and hate maven with the help of a few plugins.
In this blog i list and try to show how i used different Maven 2 plugins to make my new application system the best it can be with a maven build system.
As you can tell, i use a lot of maven and a lot of maven plugins to make my build system simple and easy for me to release the applications and also this will server a simple get up and go for any new developer that joins my team. I'll be creating a blog page for each topic/plugin and tell you how i use it and who make it a pain in the ass. So if i you are looking for info on a plugin and it is not listed yet... leave a comment and i'll get back to you ASAP.
This weekend I'm attending the No Fluff Just Stuff conference and Day 1 ended with a great keynote speech by Jared Richardson and one thing I'm planing to do is post more technical blogs ... so watch out they may be good, they may sux... but i'll posting more...