Maven testng 集成 - testng.xml 之外的测试在 Maven 测试阶段是 运行

Maven testng integration - tests outside the testng.xml are running during maven test phase

我正在尝试 运行 仅 testng.xml 中存在的测试方法。 Maven 目标-

test -Ptest1 -DargLine="-Dbrowser=firefox" -Dmaven.test.failure.ignore=true

当我尝试执行上述目标时,testng.xml 之外的测试也会被执行。(类 starting/ending 中的测试带有 *Test)

<profile>
        <id>test1</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <echo>Using env.test1.properties</echo>
                                    <copy file="src/test/resources/env.test1.properties"
                                        tofile="src/test/resources/env.properties" overwrite="true" />
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>2.19.1</version>
                    <configuration>
                        <suiteXmlFiles>
                            <file>src/test/resources/testng.xml</file>
                        </suiteXmlFiles>
                        <systemPropertyVariables>
                            <propertyName>browser</propertyName>
                            <buildDirectory>${project.build.directory}</buildDirectory>
                        </systemPropertyVariables>

                    </configuration>
                    <!-- <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>java</goal>
                            </goals>
                        </execution>
                    </executions> -->
                </plugin>
            </plugins>
        </build>
    </profile>

我的 testng.xml 文件看起来像这样

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Maven tutorial" verbose="3" >
<test name="Testie">
    <!-- <parameter name="browser" value="firefox"></parameter> -->
    <classes>
        <class name="com.maven.tutorial.hello2Test"></class>

    </classes>
</test>

<test name="Testff">
    <!-- <parameter name="browser" value="firefox"></parameter> -->
    <classes>

        <class name="com.maven.tutorial.hello4Test"></class>
    </classes>
</test>
</suite>

当我 运行 Maven 目标时,它会执行 类 hello2Test、hello4Test 以及其他 类 以 Test 结尾的测试。

改变

 <suiteXmlFiles>
    <file>src/test/resources/testng.xml</file>
 </suiteXmlFiles>

 <suiteXmlFiles>
    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
 </suiteXmlFiles>

我不得不从

更改我的插件
 <artifactId>maven-surefire-report-plugin</artifactId>

 <artifactId>maven-surefire-plugin</artifactId>