为什么执行mvn test时不运行测试-p{profile id}

ffdz8vbo  于 2021-07-11  发布在  Java
关注(0)|答案(1)|浏览(578)

我在pom.xml中定义了我的配置文件,如下所示:

<profiles>
    <profile>
        <id>Test123</id>
        <build>
            <pluginManagement>
                <plugins>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.1</version>
                        <configuration>
                            <!-- put your configurations here -->
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0-M5</version>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/target/testdemo.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>

                </plugins>
            </pluginManagement>
        </build>
    </profile>
</profiles>

我们运行了一个命令mvntest-ptest123,没有如下所示的测试运行:cmd output
但是,我们用mvn命令运行test,它已经运行了如下所示的测试:cmd output

t5fffqht

t5fffqht1#

在查看了输出文件之后,我注意到maven编译器插件和maven surefire插件的不同版本在每个概要文件中运行。此项目是否依赖于父pom.xml?否则,将插件上的版本更改为:

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <!-- put your configurations here -->
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.12.4</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>src/target/testdemo.xml</suiteXmlFile>
                        </suiteXmlFiles>
                    </configuration>
                </plugin>

应该在版本控制不重要的情况下解决问题。

相关问题