运行 使用 Maven 项目的 yaml 文件对 Azure DevOps 管道进行测试时如何将 xml 套件名称作为参数传递

how to pass the xml suite name as parameter when running test with Azure DevOps pipeline using yaml file for Maven project

我们已经创建了一个 selenium 项目来 运行 功能测试。 我们提供烟雾套件、功能套件和回归套件。 在我的 pom 文件中,我参数化了 xml 套件名称,并在命令行中将套件名称传递给 运行,如下所示。

pom.xml

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

在命令行中,我可以将哪个套件指定给 运行,如下所示。

mvn clean test -Dsurefire.suiteXmlFiles=regression.xml

现在我已经为 运行 我的测试创建了一个 Azure DevOps 管道。 在 yaml 文件中,我将以下部分添加到 运行 pom.xml.

    steps:
  - task: Maven@3
    inputs:
     mavenPomFile: './pom.xml'

但是我如何在 yaml 文件中提及 运行 使用管道的哪个套件?

How can I mention in yaml file, which suite to run with the pipeline?

您可以在 Maven 任务的 options 字段中定义参数值。

例如:

- task: Maven@3
  displayName: 'Maven pom.xml'
  inputs:
    mavenPomFile: './pom.xml'
    goals: 'test'
    options: 'test -Dsurefire.suiteXmlFiles=regression.xml'

更多信息,您可以参考这篇关于maven task的文档。