Search code examples
junitantlrantlr3gunit

How do I use the Antlr generated junit file made by translating a gunit file


I am trying to make unit tests for multiple return values in Antlr. I have regular unit tests working using gunit. However, I am not too sure what to do with the junit Testgrammar.java file that is generated as per the instructions at http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing

I've tried running:

java -cp "./antlr.jar" Testgrammar.java

but I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: Testgrammar/java


Solution

  • It needs to be compiled linking to the build output of the grammar files and then run with:

    java org/junit/runner/JUnitCore Testgrammar