gpt4 book ai didi

maven - 使用位于 src/test/java 中的 Maven 运行 Spock 测试

转载 作者:行者123 更新时间:2023-12-04 22:10:33 25 4
gpt4 key购买 nike

我编写了一些 Spock 测试:

MyTest.groovy
ConfTest.groovy

这是 Spock 测试。它们位于 src/test/java 中,当我运行验证时,它们被跳过。当我将它们放入 src/test/groovy Maven 时找到它们。当它们位于 src/test/java 中时,我可以配置 Maven 来查找它们吗?我的 Maven 配置是:

 <!-- Groovy compilation -->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<configuration>
<providerSelection>1.8</providerSelection>
<source/>
</configuration>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.8</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.7-groovy-1.8</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useFile>false</useFile>
<includes>
<include>**/*Test.*</include>
</includes>
</configuration>
</plugin>

最佳答案

将此添加到插件级别的 GMaven 配置中:

<configuration>
<testSources>
<testSource>
<directory>${pom.basedir}/src/test/java</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>

更新:或在执行级别添加此内容(参见 groovy:testCompile goal documentation ):

<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<sources>
<source>
<directory>${pom.basedir}/src/test/java</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</sources>
</configuration>
</execution>

关于maven - 使用位于 src/test/java 中的 Maven 运行 Spock 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27418349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com