好吧,标题写得好长. /sample-code/examples/java/testng 1.改造Report的呈现方式 <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还得注册一下监听器,这个放在testng.xml中去注册,就不写在POM里了.maven-surefire-plugin插件里配置一个参数,用于接收不同的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的监听器. 3.配置Jenkins 勾选参数化构建,创建2个参数 第1个参数是创建一个文件夹,并且返回文件夹路径,这个在后面发邮件要用到. ![]() 第2个参数是返回testng.xml的名字,这里因为我只有一个,所以直接返回了,后面这里面可以自己加条件判断是返回哪个testng.xml的名字.比如1\3\5跑testng1.xml,2\4\6跑testng2.xml ![]()
构建触发器使用定时触发方式,不截图了.
构建后运行一下Python的脚本,用途是拷贝文件,将生成的ReportNG报告拷贝到上面由参数1创建的目录下.而这个目录同时也是Apache的网站目录,这样就可以直接通过URL看到测试报告了.
最后,总结一下 扩展一下: |
|
来自: instl > 《android-ios》