java - Maven TestNG - 无法从命令行指定测试套件

标签 java maven testng

我试图通过从命令行指定测试套件来从命令行运行我的测试。在我的 pom 文件中,它显示“无法解析符号‘suiteXmlFile’(对于 ${suiteXmlFile)。如果我在 pom 文件中指定 WebCheckout.xml 的名称,它会起作用,但我希望能够从命令行运行它,例如这个:

mvn clean test -Dsurefire.suiteXmlFiles=WebCheckout.xml

我一直在关注本教程:

http://www.seleniumeasy.com/maven-tutorials/choose-selected-testng-xml-files-to-execute-using-maven

我的pom文件配置如下:

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

请有人告诉我哪里出了问题。

最佳答案

This is an issue affecting 2.12 (以及可能的早期版本),所以只需使用 Surefire 插件 version >= 2.18.1它已被修复的地方。我尝试了 2.21.0(最新的 ATM),它按预期工作(尽管我的 XML 位于 test/resources 目录中,所以我必须指定 -Dsurefire.suiteXmlFiles=src\test\resources\test.xml)

关于java - Maven TestNG - 无法从命令行指定测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49174963/

相关文章:

java - 初学者编码器 : Java (Processing) and Leap Motion Controller Tutorials?

java - 将 Maven 父 pom/bom (没有 java src)发布到 Nexus 的正确方法是什么

eclipse - TestNG eclipse插件在哪里

java - 当 Selenium Job 通过 Ant 运行时,ExtentReports 导致失败

java - Java 中的 StringTokenizer。为什么要多加一个空格

java - Google Cloud Dataflow 无法在 Google Storage 中找到父目录

java - 具有多级多态类型层次结构的 Jackson 反序列化器

css - 在 MyEclipse 中保存时自动运行 maven,无需提交元素文件

Maven 搜索 site.xml 缺少的英语语言环境

spring - 事务注解避免服务被 mock