可以从命令行分别将 pom.xml 设置为 运行 testNG(UI perf.tests) 测试和 jUnit(unit tests) 测试吗?

Can pom.xml be set up to run testNG(UI perf. tests) tests and jUnit(unit tests) tests separately, from command line?

该流程要求在批准拉取请求之前在分支上执行测试。由于 testNG 用于 UI Selenium 测试和 jUnit 用于单元测试,pom.xml 插件必须像这样设置:

<plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>${surefire.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-testng</artifactId>
                    <version>${surefire.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

UI 测试是 运行 和测试 xml 套件,必须在 pom.xml 的某处定义(不确定该行放在哪里)。能否设置 pom.xml 以便单独进行测试?例如mvn -DsuiteXmlFile=/path/to/file 和`mvn -Dtest=package.with.unit.tests'

是的,你可以做到。您需要制作两个具有不同名称的单独 testng 文件,并在一个 testng 中添加单元测试,在另一个中添加性能测试,您可以从 pom.xml 对其进行参数化,例如:

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