0

我在 Eclipse 中有一个 groovy 项目。我必须从 Gradle 更改为 Maven,现在我无法运行其中存在的测试。

这是项目的结构:

在此处输入图像描述

以下是 pom.xml 的内容:

    <dependencies>
    ...
    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>1.0-groovy-2.4</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
                <compilerArguments>
                    <indy />
                    <!-- optional; supported by batch 2.4.12-04+ -->
                ...
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    ...
                </execution>
                <execution>
                    <id>add-test-source</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/test/groovy</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>

但是,如果我执行 mvn clean install,则不会运行测试。这是控制台的输出:

在此处输入图像描述

4

1 回答 1

0

我们拥有的测试用例称为 Spec 而不是 Test,固定如下:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <includes>
                    <include>**/*Spec.class</include>
                </includes>
            </configuration>
        </plugin>
于 2018-09-26T14:49:07.617 回答