我将项目划分为模块,每个模块都有单个 XML 套件,其中包含要运行的测试类。我通过传递一个变量在不同的环境中使用 maven 命令运行测试,-Denv=ENV_ALIAS
使用System.getProperty("env")
.
我正在重新调整我的解决方案以处理不同国家/地区版本的应用程序(不同版本会禁用某些功能或某些流程不同)。我传递了一个变量-DcountryCode=COUNTRY_ALIAS
,因此测试使用不同的 URL,但默认情况下所有测试都在运行。
我想根据countryCode
套件级别的值禁用一些测试,而不是在每种测试方法中实现切换机制。我认为 Groups 是原生的 testNG 解决方案,但它们是相当静态的,因为我需要在套件文件中对它们进行硬编码。有没有办法让它更有活力?或者,我可以在每个国家/地区专用的每个模块中创建套件,但我需要指向 TestNG 来运行一个合适的套件(我该怎么做?)。
最好的处理方法是什么?有没有更好的处理方法?
我的父母 pom 最重要的部分:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.autoqa</groupId>
<artifactId>autoqa-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>autoqa-parent</name>
<modules>
<module>autoqa-common</module>
<module>autoqa-newcrm</module>
<module>autoqa-website</module>
<module>autoqa-giftshop</module>
<module>autoqa-unlimited</module>
<module>autoqa-booking</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefireVersion}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefireVersion}</version>
</dependency>
</dependencies>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/${file.name}.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<browserName>${browserName}</browserName>
<suiteName>${suiteName}</suiteName>
<countryCode>${countryCode}</countryCode>
<env>${env}</env>
</systemPropertyVariables>
<properties>
<property>
<name>surefire.testng.verbose</name>
<value>10</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>