问题描述
我正在尝试运行“ spock groovy测试以及来自maven surefire的Java junit测试”
我遵循了例子
- https://github.com/groovy/GMavenPlus/wiki/Examples#joint-compilation&
- https://github.com/groovy/GMavenPlus/wiki/Usage#configuring-gmavenplus-1
当我在pom中定义了gmavenplus + groovy插件时,将运行groovy测试,但不会运行Java测试。
当我从pom中删除了gmavenplus + groovy插件时,将运行Java测试,但不会运行groovy测试。
我的文件是
-
src / main / java / org / gw / JavaClass.java
package org.gw; public class JavaClass { }
-
src / test / java / org / gw / JavaTest.java
package org.gw; import org.junit.Test; public class JavaTest { @Test public void testMethod1() { System.out.println("testMethod1"); } }
-
src / test / groovy / org / gw / GroovyTest.groovy
package org.gw import spock.lang.Specification import spock.lang.Unroll @Unroll class GroovyTest extends Specification { def 'do a spock test'() { when: def doa = "spock test" then: println("done a " + doa) } }
-
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.gw</groupId> <artifactId>mcve</artifactId> <version>1.0-SNAPSHOT</version> <properties> <groovy.version>3.0.3</groovy.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</version> <scope>test</scope> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> <version>${groovy.version}</version> </dependency> <dependency> <groupId>org.spockframework</groupId> <artifactId>spock-core</artifactId> <version>2.0-M3-groovy-3.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,visit https://github.com/groovy/GMavenPlus/wiki --> <groupId>org.codehaus.gmavenplus</groupId> <artifactId>gmavenplus-plugin</artifactId> <version>1.10.0</version> <executions> <execution> <goals> <goal>addSources</goal> <goal>addTestSources</goal> <goal>generateStubs</goal> <goal>compile</goal> <goal>generateTestStubs</goal> <goal>compileTests</goal> <goal>removeStubs</goal> <goal>removeTestStubs</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> </plugin> <plugin> <!-- if including source jars,use the no-fork goals otherwise both the Groovy sources and Java stub sources will get included in your jar --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <!-- source plugin \> = 2.1 is required to use the no-fork goals --> <version>3.2.1</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar-no-fork</goal> <goal>test-jar-no-fork</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> </plugin> </plugins> </build> </project>
-
我的输出是
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ mcve --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running org.gw.GroovyTest done a spock test [INFO] Tests run: 1,Failures: 0,Errors: 0,Skipped: 0,Time elapsed: 0.164 s - in org.gw.GroovyTest [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1,Skipped: 0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)