在selenium java pom项目中,不使用testng.xml文件和仅使用pom.xml文件是否可以执行?

在selenium java pom项目中,不使用testng.xml文件和仅使用pom.xml文件是否可以执行?,java,maven,selenium,testng,testng.xml,Java,Maven,Selenium,Testng,Testng.xml,如何在没有Testng.xml文件的情况下仅使用pom.xml文件执行Testng和Maven否,不可能仅通过Maven执行基于Testng的测试套件,即仅使用pom.xml而不使用Testng.xml 您需要使用所需的testng.xml文件将Maven即pom.xml配置为强制配置,如下所示: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>mav

如何在没有Testng.xml文件的情况下仅使用pom.xml文件执行Testng和Maven

,不可能仅通过Maven执行基于Testng的测试套件,即仅使用
pom.xml
而不使用
Testng.xml

您需要使用所需的
testng.xml
文件将Maven即
pom.xml
配置为强制配置,如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.17</version>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.17
${suiteXmlFile}

我不能同意。根据Surefire插件文档
,只要它们(测试类)是按照默认值命名的,例如*test.java,它们将由Surefire作为TestNG测试运行。
。这意味着您只需在surefire插件配置中使用命令
mvn test
或特定测试
mvn test-Dtest=classTest
即可运行所有测试,而无需使用testng.xml和标记
。@Omeniq听起来很有趣。您能分享文档的链接吗?这里:。@Omeniq非常感谢您的链接。这可能就是为什么特别提到基于Testng的测试套件(而不是测试)的原因。