Agile project development needs to prevent problems and regressions as soon as possible. Some practices have to be established to reach this goal:
- Developing unit test
- Frequent source code commit
- Deploy application in integration environment
- Launch test
Those good practices need a strong commitment from all the developers to sustain them. Because launch all the Unit test in the developer local machine can slow down his IDE and deploying the application needs a resource to deploy the application and verify that there is no regression by launching tests.
Using a Continuous Integration Environment is a best practice to ensure that unit tests and that the project build have been done all along the application development process.
There is many Continuous Integration tool. The most known are Hudson, Continuum and Cruise Control. In this wordPress post, I chose Hudson as a sample of continuous integration tool.
The picture below presents a continuous integration environment example using Hudson, SVN, Maven and GlassFish.
Description of an example of continuous integration process
Developers synchronize there source code with repository under the revision control system (SVN). Hudson looks for changes in the SVN repository and does a checkout to local directory, run tests and does a build using Maven. Finally, it publishes report of tests execution and some code quality reports. If the build is done successfully the application is deployed to the GlassFish server.
Description of Hudson configuration
|1-||Download WAR file from Hudson web site (http://hudson-ci.org) and deploy it in an application server or in a servlet container.|
Create a new Hudson Job by clicking on the link New Job. Tape the name of project and choose Build a maven2 project. The picture bellow presents a sample of a Hudson JOB configuration. There is some fields that are configured in the picture that neads some plugins to be istalled (step4).
|3-||Install hudson Plugins for reports you may need like Checkstyle, PMD, FindBugs.|
Update project pom.xml file by adding Maven plugins.
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> <configuration> .................... ..... </configuration> </plugin> ............................ ................ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.0.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.5</version> <configuration> <enableRulesSummary>false</enableRulesSummary> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>2.5</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.4</version> </plugin> </plugins>
|5-||Commit the maven project into Subversion.|
|6-||Run a build by clicking in Build Now under the created Hudson JOB in step3. The picture below shows the results of project build. Hudson publish some reports like test results, checkstyle, findBugs, PMD and test coverage. All those reports give us an idea about code quality and application stability.|
In agile development we need to have a great code quality and good test coverage because of the lack of time and detailed functinal specification. An integration server helps a team achieve those goals by giving them a fast feedback about the source code with some detailed and amazing graphs that catch developers intention.