私はプロジェクトをモジュールに分割しました。各モジュールには、実行するテスト クラスを含む単一の XML スイートがあります。変数を渡すことにより、さまざまな環境で maven コマンドを使用してテストを実行し-Denv=ENV_ALIAS
、それらを で処理しますSystem.getProperty("env")
。
アプリケーションのさまざまな国のバージョンを処理するためにソリューションを再スケーリングしています (バージョンによって、一部の機能が無効になるか、一部のフローが異なります)。変数を渡す-DcountryCode=COUNTRY_ALIAS
ので、テストは異なる URL を使用しますが、すべてのテストはデフォルトで実行されます。
countryCode
各テストメソッドに切り替えメカニズムを実装するのではなく、スイートレベルの値に応じていくつかのテストを無効にしたいと考えています。私はグループをネイティブの testNG ソリューションと考えていましたが、スイート ファイル内にハードコードする必要があるため、かなり静的です。より動的にする方法はありますか?別の方法として、各国専用の各モジュール内にスイートを作成することもできますが、TestNG に単一の適切なスイートを実行するように指示する必要があります (どうすればよいでしょうか?)。
どのように処理するのが最善でしょうか?それを処理するためのより良い方法はありますか?
私の親は最も重要なセクションをポンポンします:
<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>