如何使用 Antlr 通过翻译 Gunit 文件生成的 junit 文件

发布于 2024-08-14 02:07:08 字数 433 浏览 4 评论 0原文

我正在尝试对 Antlr 中的多个返回值进行单元测试。我使用 Gunit 进行定期单元测试。但是,我不太确定如何处理按照 http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing

我尝试运行:

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

但出现以下错误:

线程“main”中的异常 java.lang.NoClassDefFoundError: Testgrammar/java

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不在是我 2024-08-21 02:07:08

您可以像任何其他 Java 应用程序一样运行它:使用类名,而不是文件名。

java -cp "./antlr.jar" Testgrammar

You run it like any other Java app: with the classname, not the file name.

java -cp "./antlr.jar" Testgrammar
心的憧憬 2024-08-21 02:07:08

它需要链接到语法文件的构建输出进行编译,然后使用以下命令运行:

java org/junit/runner/JUnitCore Testgrammar

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

java org/junit/runner/JUnitCore Testgrammar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文