I have project divided into modules, each module have single XML suite with test classes to run. I run tests with maven command on different environments by passing a variable -Denv=ENV_ALIAS
, handle them with System.getProperty("env")
.
I am rescaling my solution to handle different country versions of application (different version would have some features disabled or some flows are different). I pass a variable -DcountryCode=COUNTRY_ALIAS
so tests use different URLs but all tests are being run by default.
I would like to disable some tests depending on countryCode
value on suite level rather than implementing in each test method a switching mechanism.
I thought of Groups as the native testNG solution, but they are rather static as I need to hard-code them inside suite file. Is there a way to make it more dynamic?
Alternatively I can create suite inside each module dedicated to each country but I will need to point TestNG to run a single proper suite (how can I do that?).
What would be the best way to handle? Are there any better ways to handle it?
My parent pom most important sections:
<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>