2
對於每個測試,我終於使用JUnit4 @Category
運行了測試自動化;它們被標記爲PriorityHigh
,PriorityMedium
或PriorityLow
。通過在命令行上指定多個Maven配置文件來堆疊屬性
在我pom.xml
我已分別設置爲一個配置文件:
<profile>
<id>PriorityHigh</id>
<properties>
<testcase.category>com.categories.PriorityHigh</testcase.category>
</properties>
</profile>
<profile>
<id>PriorityMedium</id>
<properties>
<testcase.category>com.categories.PriorityMedium</testcase.category>
</properties>
</profile>
<profile>
<id>PriorityLow</id>
<properties>
<testcase.category>com.categories.PriorityLow</testcase.category>
</properties>
</profile>
,然後在插件部分使用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<groups>${testcase.category}</groups>
<systemPropertyVariables>
<automation.driver>${browser.name}</automation.driver>
</systemPropertyVariables>
</configuration>
</plugin>
我的問題是,當我想測試兩個中型和高,我指定
-P PriorityHigh,PriorityMedium
但是不添加/連接,它們覆蓋等等y中等測試運行。要添加額外的困難,因爲pom.xml
抱怨$ {} testcase.category僅在配置文件中存在,並沒有默認情況下,我必須補充一點:如果指定
<testcase.category>com.categories.PriorityHigh,com.categories.PriorityMedium,com.categories.PriorityLow</testcase.category>
任何資料。
所以兩個問題:
- 如何獲得的配置文件中的「組」節點正確疊加麼?
- 如果沒有指定配置文件(所有測試都應該運行),更好的方法來處理它?
謝謝!一個更簡單的解決方案。我唯一的抱怨是,在使用建立幫助插件,即fq.testcase.name不被識別爲在IDE中的值,因此它總是顯示在誤差值。代碼仍然編譯和測試仍然運行,但我的強迫症不喜歡紅色的名字。 – MivaScott
也許你可以通過添加一個''屬性爲''部分具有空或任意數值 –
ryanp
出於某種原因,喚醒你的IDE,當我添加空白屬性,它停止從類別加工。換句話說,它可以運行所有測試,無論優先級如何。 – MivaScott