|
好吧,標題寫得好長. /sample-code/examples/java/testng 1.改造Report的呈現(xiàn)方式 <dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
ReportNG還得注冊一下監(jiān)聽器,這個放在testng.xml中去注冊,就不寫在POM里了.maven-surefire-plugin插件里配置一個參數(shù),用于接收不同的testng.xml <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>res/${xmlFileName}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
pom里面的值留空: <properties>
<xmlFileName></xmlFileName>
</properties>
2.使用不同的testng.xml配置文件來配置不同的渠道測試case <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http:///testng-1.0.dtd" >
<suite
name="Suite"
verbose="1" >
<test name="Project_V3023" >
<packages>
<package name="com.saucelabs.appium" />
</packages>
</test>
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<usedefaultlisteners name="false" />
</suite>
這個文件用來配置選擇不同的渠道需要選擇的case,res文件夾下可以扔很多testng.xml文件用于不同的渠道.比如A渠道可以用testng1.xml,B渠道可以用testng2.xml,另外在這里面注冊一下ReportNG的監(jiān)聽器. 3.配置Jenkins 勾選參數(shù)化構建,創(chuàng)建2個參數(shù) 第1個參數(shù)是創(chuàng)建一個文件夾,并且返回文件夾路徑,這個在后面發(fā)郵件要用到. ![]() 第2個參數(shù)是返回testng.xml的名字,這里因為我只有一個,所以直接返回了,后面這里面可以自己加條件判斷是返回哪個testng.xml的名字.比如1\3\5跑testng1.xml,2\4\6跑testng2.xml ![]()
構建觸發(fā)器使用定時觸發(fā)方式,不截圖了.
構建后運行一下Python的腳本,用途是拷貝文件,將生成的ReportNG報告拷貝到上面由參數(shù)1創(chuàng)建的目錄下.而這個目錄同時也是Apache的網(wǎng)站目錄,這樣就可以直接通過URL看到測試報告了.
最后用郵件插件發(fā)一下郵件,我這里都是引用的系統(tǒng)配置里的內(nèi)容
最后,總結一下 擴展一下: |
|
|
來自: instl > 《android-ios》