Saturday, May 30, 2009

Maven integration test

I m currently doing some functional tests using a great build tool Maven (this also has been used much by Atlassian developer) on my Confluence plugin. Yep, as usualy, i got a problem on my test :P. I found there is a "Class not found exception" on the log file. The class that could not be found is JSONObject which is from json-lib. I was wondering how could this be happening. Then, I checked the classpath of my integrationt test. Forgot to mention that I use cargo to startup Tomcat for my functional test.

Checking on the classpath, i could not find any json-lib library. I thought that it is added automatically as I have specified the dependency of my plugin, but in fact it is not. Thus, what I did is to copy the dependency so that the error does not reoccur anymore. Maven defines 3 phases on integration test, they are pre integration test, integration test and post integration test. I didnt choose one of them but I choose phase package. 
This phase will be executed before pre integration test. The first time I was trying pre-integration phase, it does not work. Thus, I pick the phase before executing integration phase and the result it works like a charm.

The following is the code that I have:

There is a few ways to copy any data to any directory using maven. A few plugins available to do that. You can use maven-antrun-plugin, you can reference to maven documentation about plugins availabe.

No comments: