[英]How to generate JUnit sources using maven-gunit-plugin
I have maven configured to run gunit (an ANTLR grammar unit testing tool) through the maven-gunit-plugin . 我有maven配置为通过maven-gunit-plugin运行gunit (一个ANTLR语法单元测试工具)。 gunit, however, has two different modes.
然而,gunit有两种不同的模式。 The first mode causes gunit to act as an interpreter, reading through the *.gunit (or *.testsuite) file, interpreting it, and displaying the results.
第一种模式使gunit充当解释器,读取* .gunit(或* .testsuite)文件,解释它并显示结果。 It can be configured as such:
它可以这样配置:
<plugin>
<groupId>org.antlr</groupId>
<artifactId>maven-gunit-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<id>maven-gunit-plugin</id>
<phase>test</phase>
<goals>
<goal>gunit</goal>
</goals>
</execution>
</executions>
</plugin>
The second mode causes gunit to generate source code that can be run by JUnit. 第二种模式导致gunit生成可由JUnit运行的源代码。 How can I instruct the maven-gunit-plugin to generate JUnit sources instead of acting as an interpreter?
如何指示maven-gunit-plugin生成JUnit源而不是充当解释器?
A few notes: 几点说明:
EDIT / RESOLUTION: 编辑/决议:
After reading the various responses, I downloaded the ANTLR source code, which includes the maven-gunit-plugin. 在阅读了各种回复后,我下载了ANTLR源代码,其中包含maven-gunit-plugin。 The plugin does not support junit generation.
该插件不支持JUnit的一代。 It turns out that the codehaus snapshot of the gunit-maven-plugin and the exec plugin are currently the only options.
事实证明,gunit-maven-plugin和exec插件的codehaus快照是目前唯一的选择。
I found a discussion through MNG-4039 that is illustrated with a
maven-gunit-plugin
gunit-maven-plugin
sample. 我发现了一个讨论通过MNG-4039 ,其与所示的
maven-gunit-plugin
gunit-maven-plugin
样品。 I'll let you read the whole article but, according to the author, you should end up with something like this: 我会让你阅读整篇文章,但据作者说,你最终会得到这样的结论:
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
<version>3.1.1</version>
</dependency>
<!-- Here is the 'extra' dep -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
<version>3.1.1</version>
<!-- we try to use scope to hide it from transitivity -->
<scope>test</scope> <!-- or perhaps 'provided' (see later discussion) or 'import' (maven >= 2.0.9) -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gunit-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I didn't test this configuration myself and can't thus confirm everything is working out of the box. 我自己没有测试这个配置,因此不能确认一切都是开箱即用的。 I don't even know if the plugin has been released in a non SNAPSHOT version.
我甚至不知道该插件是否已在非SNAPSHOT版本中发布。 The only thing I can confirm is that it seems indeed very hard to find "real" documentation about the
maven-gunit-plugin
. 我唯一可以证实的是,找到关于
maven-gunit-plugin
“真实”文档似乎确实很难。
I found out so far there is no GUnit-functionality (be it JUnit Test-Generation or direct invocation of GUnit) for maven right now.
我发现到目前为止还没有针对maven的GUnit功能(无论是JUnit Test-Generation还是直接调用GUnit)。 I already mailed with Jim Idle concering the state of GUnit in the
我已经和吉姆·艾德尔(Jim Idle)一起邮寄了一份关于GUnit状态的信息
antlr3-maven-plugin and learned that there is a patch to the old version of the maven-plugin waiting in the queue.antlr3-maven-plugin并了解到队列中等待的旧版maven-plugin有一个补丁。
I think this workaround that is the only option. 我认为这种解决方法是唯一的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.