In every software development project there is the need for quality assurance and quality management for the code. To make this work more efficient there exist a big number of tools to do this task.
For the ADempiere and iDempiere project I was working together with Redhuan (red1.org) on some Fitnesse test integration to run them automatically. The goal was to have a test suite applied on the current ADempiere code with all migration done to the database.
At the start of the project I defined following steps:
- Setup Jenkins for doing the tests automatically
- Code some scripts for creating an up to date database with all migration scripts applied
- Run all the test triggered by Jenkins
While doing the work I was facing some problems with the process on an headless build server. The tests for the ADempiere client needed some graphical interface to work. To work around this issue I installed a minimal X11 environment and started the Fitnesse test software within this X11 environment. Now when the tests a run the popups can be shown by the code and triggered by Fitnesse.
1. Setup Jenkins
The default installation of Jenkins was done by me some time ago and the Jenkins is already running some build processes for the iDempiere project to build the OSGi based code using Buckminster.
For the testing of the Fitnesse tests we decided to use the 361 code base maintained by Carlos Ruiz from Kenai repository.
To keep things clear I first created the build job to run the build of ADempiere with the ant task.
This is quite straight forward and no magic. Just let the Ant plugin call the complete target and go for it.
2. The up to date database script
To recreate a fully updated database I created a short collection of commands within a shell script which looks like this:
#!/bin/bash # #This script installes fresh ADempeire Postgres database #Author Dominik Zajac #Date: 10-13-2011 #Version: 0.0.1 WORKSPACE=/var/lib/jenkins/jobs/ADempiere361-Kenai/workspace/ SCRIPTHOME=/opt/adempiere_database_tool #Remove existing database /usr/bin/dropdb -U adempiere adempiere echo "Old Database removed"; #Import new fresh database /usr/bin/createdb -U adempiere adempiere echo "Database created"; /usr/bin/psql -U adempiere adempiere < $SCRIPTHOME/adempiere.dump echo "Database imported"; #Apply migration scripts $WORKSPACE/migration/migrate_postgresql.sh \ $WORKSPACE/migration/360lts.010-release commit \ |psql -U adempiere -d adempiere echo "Migration scripts applied"
What the script does is quite clear. It loads a default database and applies all necessary migrations scripts to it to have a fully prepared database for testing.
3. Run all the Fitnesse test triggered by Jenkins
This two tasks within that build job are the main effort from Redhuan D. Oon and me. Red1 consolidated all the Fitnesse tests to one project so it was more easy to integrate it into the build server and run it. I created the sql database script which is very very basic and just runs commands step by step for database setup. The part for Fitnesse in Jenkins is starting a new instance of Fitnesse each time the tests are called and executes the tests within this instance. The results will be written to the fitnesse-restults.xml.
Jenkins takes care of the job to look if there are new changes in the repository every minute and reruns the job if there where some commits.
The next tasks would be:
- migrate this testing stuff to iDempiere OSGi platform
- write some presentation layer for the xml result file
- implement a second instance for manual testing by some interested users