Использование GMavenPlus для запуска тестов spock groovy вместе с тестами java junit от maven surefire
Я пытаюсь запустить "тесты spock groovy вместе с тестами java junit от maven surefire"
Я следил за примерами
Когда у меня есть плагины gmavenplus + groovy, определенные в pom, запускается тест groovy, но не тест java.
Когда у меня удалены плагины gmavenplus + groovy из pom, запускается java-тест, но не Groovy-тест.
У меня есть файлы
SRC / основной / java / org / gw / JavaClass.java
package org.gw; public class JavaClass { }
SRC / тест / 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, Failures: 0, Errors: 0, Skipped: 0