Thursday, November 29, 2007

Junit,Emma & PMD with CruiseControl

Junit is a framework for java test cases .

The test cases have setup s teardown sections for initialization .Junit s can be executed using ant target junit fork .Individual classes can be executed or batch processing can be done.

Emma is open source code coverage generator.

http://emma.sourceforge.net/

Emma will instrument the jar , which are refereed by junit test cases for execution .

Instrumentation can be done by

java -cp emma.jar emma instr -m overwrite –cp abc.jar

This will produce a coverage file coverage.em(Also the size of the instrumented abc.jar will increase)

Exclude rmi classes(Stub and skeleton) by using –ix option while instrumenting the classes or jars.

Later the junit cases can be run with junit fork ant utility, pointing to the instrumented jar.

This will generate coverage information in the form of coverage.ec

Next reports can be generated using the coverage information obtained.

Java -cp emma.jar emma report -sp ${sourcecode} -r html -in coverage.em,coverage.ec"

Providing the {sourcecode} location will get the code in the result, which can be html , xml etc .

Coverage will be provided for any functionality which refers to the instrumented jar.

PMD is a framework for maintaining the coding standards in java files.

On proving the ruleset file(one which has the customised coding standards), the follwing command will generate the coding standards violations existing in the source code in the required format.



Cruisecontrol has pluggins for junit test cases and PMD execution .

In the configuration file , under the section is provided . On giving the xml logs obtained from the junit amd pmd executions ,gives a collaborated report for build and junit execution of the product code.

 
Free Domain Names @ .co.nr!