I am invoking junit tests programmatically. Gotto generate the reports as well. For that purpose I have added XMLJUnitResultFormatter (from ant-junit) as a listener to the TestResult. i get the following runtime error:

java.lang.NoClassDefFoundError: junit/framework/TestListener

at the statement:

XMLJUnitResultFormatter resultFormatter = new XMLJUnitResultFormatter();

However following statement runs fine:

TestListener listener = new TestRunner(); //both are junit framework classes and are accessible.

This means that the problem is when ant-junit class XMLJUnitResultFormatter tries to access TestListener.

Any ideas/suggestions?