Sunday, June 20, 2010

How to do Apache Derby Testing

Here I am going to log some important things which I had done during test Derby.
Here I have done two testings.
  1. derbyall test
  2. JUnit test
Before test Derby make sure that you build the trunk (need to put junit.jar (download) file in the tools/java folder if you don't skip the tests). You can build the truck by executing "ant all" command in the trunk and it will create classes folder which include build files. 

To run the test you need to set some class variables. One is path to classes which includes Derby build files. And path to the following jar files
  1. JUnit.jar (download)
  2. jakarta-oro-2.0.8.jar(download)
Here is my CLASSATH setting command I used,
export CLASSPATH=/home/eranda/Desktop/DERBY/trunk/classes:/home/eranda/Desktop/DERBY/trunk/tools/java/junit.jar:/home/eranda/Desktop/DERBY/trunk/tools/java/jakarta-oro-2.0.8.jar

Now we can start the the testing.

NOTE: Need to do the test in a separate folder not to mixes with others.

To run the derby all tests,
java org.apache.derbyTesting.functionTests.harness.RunSuite derbyall

This will do derbyall test and give you result files. Among them there are few important files which summarize the tests.
  1. derbyall_report.txt- in which include the summery of the tests
  2. derbyall_pass.txt- in which include the tests passed
  3. derbyall_fail.txt- in which include the tests failed
To run the JUnit all tests,
java -Xmx512m -XX:MaxPermSize=128m junit.textui.TestRunner org.apache.derbyTesting.functionTests.suites.All

Normally I pump this JUnit test results to a file by adding the following piece of code to the above execution.
>junitAll.out 2>&1

In JUnit tests it will return dots(.) for every passes test, 'E' for every error tests and 'F' for every failures. Also at the end it will show the stack trace of every errors and failures. 

If it need to run single test then it can be run using the following command,

java junit.textui.TestRunner PathToFile.TestName

for example I ran following command to test the InbetweenTest which is a JUnit test for testing the inbeween syntax.

java junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.lang.InbetweenTest 

Here I want to thank Bryan Pendleton (Apache Derby committer) whom I learnt most of this from.