我正在使用testNG和Appium来运行移动自动化。以下是我的代码:
package my.app.package;
public class TestDataProvider {
@DataProvider(parallel=false)
public static Object[][] GenericDataProviderWithNoCustomCapabilities() {
return new Object[][] {
{"", "Nexus_5_API_21_x86", "19", "C:\\Users\\me\\Desktop\\app.apk", "http://127.0.0.1:4723/wd/hub", ScreenOrientation.PORTRAIT},
{"", "Nexus_5_API_21_x86", "20", "C:\\Users\\me\\Desktop\\app.apk", "http://127.0.0.1:4723/wd/hub", ScreenOrientation.LANDSCAPE}
};
}
}
在测试套件类中:
public class SanityTestAndroid {
private ScreenOrientation orientation;
@Factory(dataProviderClass = my.app.package.TestDataProvider.class, dataProvider="GenericDataProviderWithNoCustomCapabilities")
public SanityTestAndroid(String version, String avd, String platformVersion, String appPath, String targetPath, ScreenOrientation orientation) throws Exception {
AndroidDriverFactory.create(version, avd, platformVersion, appPath, targetPath);
this.orientation = orientation;
}
@Test()
public void testLoginInLandscape() throws Exception {
if (orientation == ScreenOrientation.LANDSCAPE) {
...}
...}
testNG.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="android automation" parallel="false">
<test name="com.tribehr.qa.tests">
<classes>
<class name="my.app.package.test.SanityTestAndroid "/>
</classes>
</test>
</suite>
我已将所有testNG并行设置为false(据我所知),但在运行测试时我仍然看到它并行运行。我不知道为什么,以及如何让它在队列中运行两次(因为给出了两个数据集)。
答案 0 :(得分:0)
TestNG默认按顺序执行测试。如果它们同时执行,则必须有设置才能执行此操作。
答案 1 :(得分:0)
您需要将 group-by-instances =&#34; true&#34; 属性添加到套件* .xml中的测试元素中。在其他情况下,它并不像你期望的那样工作。