简体   繁体   English

如何在NetBeans构建周期中集成gUnit(ANTLR语法测试)?

[英]How-to integrate gUnit ( ANTLR grammar testing ) in the NetBeans build cycle?

Background: I am using NetBeans 7.1 and ANTLR 3.4. 背景:我正在使用NetBeans 7.1和ANTLR 3.4。 I have integrated java code generation in the NetBeans build script using the following tutorial: http://wiki.netbeans.org/Integrating_ANTLR_without_learning_Ant . 我使用以下教程在NetBeans构建脚本中集成了Java代码生成: http : //wiki.netbeans.org/Integrating_ANTLR_without_learning_Ant I want to use automated tests for testing grammars. 我想使用自动化测试来测试语法。 I have read about gUnit on the ANTLR site. 我已经在ANTLR网站上阅读了有关gUnit的信息。 There are, supposedly, two modes: one 'direct' method and another method which generates jUnit code. 据推测,有两种模式:一种“直接”方法和另一种生成jUnit代码的方法。 I have worked with jUnit before. 我以前使用过jUnit。

Question(s): 问题:

  • What method is advisable? 建议采用哪种方法? Direct or via jUnit? 直接还是通过jUnit? Or perhaps both? 还是两者兼而有之?
  • What should I do to integrate gUnit in the NetBeans build cycle? 我应该怎么做才能将gUnit集成到NetBeans构建周期中?

My personal preference is to use JUnit since then you can run the generated tests like any other JUnit test in NetBeans. 我个人比较喜欢使用JUnit,因为这样您就可以像NetBeans中的任何其他JUnit测试一样运行生成的测试。

To get the JUnit classes you need to run the org.antlr.gunit.Interp class (in the Antlr JAR) as a Java program with the -o flag. 要获取JUnit类,您需要使用-o标志将org.antlr.gunit.Interp类(在Antlr JAR中)作为Java程序运行。 The result will be JUnit classes in the same dir as the gunit file. 结果将是与gunit文件位于相同目录的JUnit类。 Add the generated source to your project and compile/run. 将生成的源添加到您的项目中并进行编译/运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM