[antlr-interest] more gUnit suggestions
Jared Bunting
jared.bunting at peachjean.com
Mon Nov 10 22:37:18 PST 2008
I was looking at writing a Maven plugin around gUnit tonight, and I ran
into two issues that I was hoping could be addressed.
My approach was to use the JUnitCodeGen class to generate JUnit classes
during maven's generate-test-sources phase.
The first issue that I ran into was that I was unable to specify the
output directory. I was able to get around this by extending
JUnitCodeGen and overriding "writeTestFile", but this seems a bit
hackish, as I had to throw away the "dir" parameter to this method
(which is hard coded as "."). Something like a "setOutputDirectory"
that was then used in the call to writeTestFile would be much more
elegant here.
The second issue was in the constructor, where it invokes
"Class.forName(...)". When I'm invoking this from maven, my generated
parser classes likely aren't in the system ClassLoader. However, I am
able to load them all into a child ClassLoader, so it would be great if
there were a way to provide a ClassLoader to JUnitCodeGen so that it can
load the parser class from there instead. Unfortunately, I wasn't able
to work around this one without modifying JUnitCodeGen.
Is this the preferred way to access GUnit programmatically? I'm open
for suggestions.
Thanks,
Jared
More information about the antlr-interest
mailing list