一、测试类*注1
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">package</span> <span class="n">com</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">testerhome</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">io.appium.java_client.android.AndroidDriver</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">java.net.MalformedURLException</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">java.net.URL</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.openqa.selenium.By</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.openqa.selenium.WebElement</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.openqa.selenium.remote.DesiredCapabilities</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.testng.annotations.BeforeSuite</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.testng.annotations.Parameters</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.testng.annotations.Test</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.testng.annotations.BeforeClass</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kn" style="color: rgb(170, 34, 255); font-weight: bold;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: bold;">org.testng.annotations.AfterClass</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">class</span> <span class="nc" style="color: blue;">Suite1</span> <span class="o" style="color: rgb(102, 102, 102);">{</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="n">String</span> <span class="n">port</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="n">String</span> <span class="n">udid</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">private</span> <span class="n">AndroidDriver</span> <span class="n">driver</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="nd" style="color: rgb(170, 34, 255);">@Test</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="kt" style="color: rgb(0, 187, 0); font-weight: bold;">void</span> <span class="n">switches</span><span class="o" style="color: rgb(102, 102, 102);">()</span> <span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">throws</span> <span class="n">InterruptedException</span> <span class="o" style="color: rgb(102, 102, 102);">{</span>
<span class="n">WebElement</span> <span class="n">sound</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">driver</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">findElementByAndroidUIAutomator</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"new UiSelector().text(\"Sound\")"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">sound</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">click</span><span class="o" style="color: rgb(102, 102, 102);">();</span>
<span class="n">System</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">out</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">println</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"checked"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">Thread</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">sleep</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="mi" style="color: rgb(102, 102, 102);">2000</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">System</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">out</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">println</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="n">Thread</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">currentThread</span><span class="o" style="color: rgb(102, 102, 102);">());</span>
<span class="o" style="color: rgb(102, 102, 102);">}</span>
<span class="nd" style="color: rgb(170, 34, 255);">@BeforeSuite</span>
<span class="nd" style="color: rgb(170, 34, 255);">@Parameters</span><span class="o" style="color: rgb(102, 102, 102);">({</span> <span class="s" style="color: rgb(187, 68, 68);">"port"</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="s" style="color: rgb(187, 68, 68);">"udid"</span> <span class="o" style="color: rgb(102, 102, 102);">})</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="kt" style="color: rgb(0, 187, 0); font-weight: bold;">void</span> <span class="n">beforeSuite</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="n">String</span> <span class="n">port</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="n">String</span> <span class="n">udid</span><span class="o" style="color: rgb(102, 102, 102);">)</span> <span class="o" style="color: rgb(102, 102, 102);">{</span>
<span class="k" style="color: rgb(170, 34, 255); font-weight: bold;">this</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">port</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">port</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="k" style="color: rgb(170, 34, 255); font-weight: bold;">this</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">udid</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">udid</span><span class="o" style="color: rgb(102, 102, 102);">;</span>
<span class="o" style="color: rgb(102, 102, 102);">}</span>
<span class="nd" style="color: rgb(170, 34, 255);">@BeforeClass</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="kt" style="color: rgb(0, 187, 0); font-weight: bold;">void</span> <span class="n">beforeClass</span><span class="o" style="color: rgb(102, 102, 102);">()</span> <span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">throws</span> <span class="n">MalformedURLException</span><span class="o" style="color: rgb(102, 102, 102);">{</span>
<span class="n">System</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">out</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">println</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="n">port</span> <span class="o" style="color: rgb(102, 102, 102);">+</span> <span class="n">udid</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">DesiredCapabilities</span> <span class="n">capabilities</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="k" style="color: rgb(170, 34, 255); font-weight: bold;">new</span> <span class="n">DesiredCapabilities</span><span class="o" style="color: rgb(102, 102, 102);">();</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"deviceName"</span><span class="o" style="color: rgb(102, 102, 102);">,</span><span class="s" style="color: rgb(187, 68, 68);">"device"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"automationName"</span><span class="o" style="color: rgb(102, 102, 102);">,</span><span class="s" style="color: rgb(187, 68, 68);">"Appium"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"platformVersion"</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="s" style="color: rgb(187, 68, 68);">"4.4"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"udid"</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="n">udid</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"appPackage"</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="s" style="color: rgb(187, 68, 68);">"com.android.settings"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">setCapability</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"appActivity"</span><span class="o" style="color: rgb(102, 102, 102);">,</span> <span class="s" style="color: rgb(187, 68, 68);">".Settings"</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="n">driver</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="k" style="color: rgb(170, 34, 255); font-weight: bold;">new</span> <span class="n">AndroidDriver</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="k" style="color: rgb(170, 34, 255); font-weight: bold;">new</span> <span class="n">URL</span><span class="o" style="color: rgb(102, 102, 102);">(</span><span class="s" style="color: rgb(187, 68, 68);">"http://127.0.0.1:"</span> <span class="o" style="color: rgb(102, 102, 102);">+</span> <span class="n">port</span> <span class="o" style="color: rgb(102, 102, 102);">+</span> <span class="s" style="color: rgb(187, 68, 68);">"/wd/hub"</span><span class="o" style="color: rgb(102, 102, 102);">),</span> <span class="n">capabilities</span><span class="o" style="color: rgb(102, 102, 102);">);</span>
<span class="o" style="color: rgb(102, 102, 102);">}</span>
<span class="nd" style="color: rgb(170, 34, 255);">@AfterClass</span>
<span class="kd" style="color: rgb(170, 34, 255); font-weight: bold;">public</span> <span class="kt" style="color: rgb(0, 187, 0); font-weight: bold;">void</span> <span class="n">afterClass</span><span class="o" style="color: rgb(102, 102, 102);">()</span> <span class="o" style="color: rgb(102, 102, 102);">{</span>
<span class="n">driver</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="na" style="color: rgb(187, 68, 68);">quit</span><span class="o" style="color: rgb(102, 102, 102);">();</span>
<span class="o" style="color: rgb(102, 102, 102);">}</span>
<span class="o" style="color: rgb(102, 102, 102);">}</span>
二、连接两个Android设备或启动两个虚拟机
使用
adb devices
获取udid
三、项目路径下新建两个testng.xml
testng1.xml
<span class="cp" style="color: rgb(176, 178, 176);"><?xml version="1.0" encoding="UTF-8"?></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><suite</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"Suite1"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><parameter</span> <span class="na" style="color: rgb(187, 68, 68);">name =</span> <span class="s" style="color: rgb(187, 68, 68);">"port"</span> <span class="na" style="color: rgb(187, 68, 68);">value =</span> <span class="s" style="color: rgb(187, 68, 68);">"4723"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><parameter</span> <span class="na" style="color: rgb(187, 68, 68);">name =</span> <span class="s" style="color: rgb(187, 68, 68);">"udid"</span> <span class="na" style="color: rgb(187, 68, 68);">value =</span> <span class="s" style="color: rgb(187, 68, 68);">"emulator-5554"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><test</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"Test"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><classes></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><class</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"com.testerhome.Suite1"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></classes></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></test></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></suite></span>
testng2.xml
<span class="cp" style="color: rgb(176, 178, 176);"><?xml version="1.0" encoding="UTF-8"?></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><suite</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"Suite2"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><parameter</span> <span class="na" style="color: rgb(187, 68, 68);">name =</span> <span class="s" style="color: rgb(187, 68, 68);">"port"</span> <span class="na" style="color: rgb(187, 68, 68);">value =</span> <span class="s" style="color: rgb(187, 68, 68);">"4725"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><parameter</span> <span class="na" style="color: rgb(187, 68, 68);">name =</span> <span class="s" style="color: rgb(187, 68, 68);">"udid"</span> <span class="na" style="color: rgb(187, 68, 68);">value =</span> <span class="s" style="color: rgb(187, 68, 68);">"emulator-5556"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><test</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"Test"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><classes></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"><class</span> <span class="na" style="color: rgb(187, 68, 68);">name=</span><span class="s" style="color: rgb(187, 68, 68);">"com.testerhome.Suite1"</span><span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;">/></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></classes></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></test></span> <span class="nt" style="color: rgb(0, 128, 0); font-weight: bold;"></suite></span>
四、开启两个appium server*注2、注3
第一个:
Port:4723
bootstrapPort:4724
第二个:
Port:4725
bootstrapPort:4726
五、导出依赖*注4
因为是用maven工程创建的,所以先导出依赖到项目路径下的lib文件夹
mvn dependency:copy-dependencies -DoutputDirectory=lib
六、执行测试
先用Maven串行执行一次以编译出Class文件
mvn clean test
然后
java -classpath ".\target\test-classes" -Djava.ext.dirs=lib org.testng.TestNG -suitethreadpoolsize 2 testng1.xml testng2.xml
如果没有配置TestNG环境变量
java -classpath ".\target\test-classes;D:\Programs\testng-6.8\testng-6.8.jar" -Djava.ext.dirs=lib org.testng.TestNG -suitethreadpoolsize 2 testng1.xml testng2.xml
七、查看报告
默认在项目路径下的test-output文件夹
注1:
这个测试类没有指定app路径,如果指定,同时unzip的时候会冲突。目前是复制了多个apk。
File app = new File(appDir, "AppName"+port+".apk");
并在appium server指定不同的临时文件路径,比如:
--tmp D:\tem1
--tmp D:\tem2
注2:
两个端口的介绍可以看这两个链接:
appium 自动化测试教程 ppt(第二版)
Appium Android Bootstrap源码分析之简介
注3:
如果使用到Selendroid或Chromium,还需要指定其他端口(需要修改测试类)
Selendroid port:8080
Selendroid port:8081
Chromium port:9515
Chromium port:9516
注4:
本来准备直接用mvn test并行执行的,但没试出来传suitethreadpoolsize参数的办法
这可以成为appium并行执行的指导文章。大赞!不过你试过跑ui的用例了么?
第一个:
Port:4723
bootstrapPort:4724
第二个:
Port:4725
bootstrapPort:4726
可以解释下 这两个端口的意思
不错, 已经开始用maven了, maven和gradle都集成了一些测试约定流程。 目前貌似没多少人熟悉。
@lihuazhang 没记错第一个应该是脚本作为client和appiumserver通信的端口,后者是mobile device和appium通信的端口,也是android上特有的。
#2楼 @lihuazhang
跑过ui用例,有什么问题吗?
帖子有更新。
#7楼 @sanlengjingvv 我执行mvn clean test的时候报错
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:testCompile (default-testCompile) on project mytest: Compilation failure: Comp
ilation failure:
[ERROR] /E:/Users/Administrator/workspace/mytest/src/test/java/appiumdemo/mytest
/StuAppTest.java:[13,44] 程序包org.openqa.selenium.browserlaunchers不存在
[ERROR] /E:/Users/Administrator/workspace/mytest/src/test/java/appiumdemo/mytest
/TeaAppTest.java:[13,44] 程序包org.openqa.selenium.browserlaunchers不存在
这个是为什么
#9楼 @nancy2896
这是Maven的问题,去看看Maven的书或资料吧。光看错误只能猜咯,maven配置、pom写错、依赖没下完等等……
完全按这个帖子来的前提是能正确用命令行执行Maven和TestNG。
#6楼 @lihuazhang 首先是Appium的Wrapper可以重启,有端口分配的功能。然后case的并发级别设置为 parallel="methods" 。 然后在每个case跑之前去获取一个Device和一个可用的Appium,跑完再把Device放回去。这里主要是Device的取和放,要做到阻塞,这样就可以控制并行执行
#13楼 @lihuazhang
afterMethod 或 afterClass,Suite 取决于我们对Appium稳定性的把控吧。
Appium Server
#10楼 @sanlengjingvv 传suitethreadpoolsize参数
suitethreadpoolsize参数是什么意思啊?
#15楼 @nancy2896
http://testng.org/doc/documentation-main.html
这个页面搜suitethreadpoolsize
@sanlengjingvv 这样跑的话,生成的测试报告只有一份,testng2.xml会覆盖testng1.xml.
我用maven的pom.xml去配置testng.xml,但是跑下来的结果是,串行跑,一台跑完去跑另外一台,求指教,如何能并行跑。
代码如下:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
...
<suiteXmlFiles>
<suiteXmlFile>testng2.xml</suiteXmlFile>
<suiteXmlFile>testng1.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
这个帖子里没有用maven去调用testng,maven只是用来管理依赖,最后是导出依赖用命令行调用testng,在命令行里传入suitethreadpoolsize参数利用testng提供的多线程功能并行执行。
testng提供了test、method、suit等几种并行方式,开始我也是准备用maven调用testng的,后来发现test、method之类都可以,只有suit不能做到并行,但我需要的是suit级的并行,所以就换成导出依赖命令行执行这种方式了。
按你的执行方法报告会不会覆盖我没试,不过报告是可以指定目录的,outputDirectory
http://testng.org/doc/documentation-main.html#logging-xml-reports