首页 > 解决方案 > Maven - 能够运行一组测试但不能运行单个测试

问题描述

在我的 pom 文件中,我将定义为

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <groups>Web</groups>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

当我使用以下命令行在控制台中运行时,它可以工作

mvn -Dgroups=Web

然而,当我跑一个像

mvn -Dtest=MyTest

Maven 显示错误[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-cli) on project test-benchmarks: No tests were executed!(设置 -DfailIfNoTests=false 以忽略此错误。) -> [Help 1] 因此,我必须删除<groups>Web</groups>POM 文件中的标记,才能正常运行单个测试。有没有人帮我修复它?谢谢

标签: mavenmaven-surefire-plugin

解决方案


推荐阅读