我们将 QAF 用于我们的移动自动化。.bdd 文件中有一个步骤很常见,实际上也是许多测试的第一步。
META-DATA: {"author":"<XXX>","description":"SRS-HLP-001-001", "fullReset":true ,groups:[ "EXISTING_USER" , "IOS" , "ANROID" , "REGRESSION_1" , "HELP" ]}
Given User waits for sometime
步骤定义为:
@QAFTestStep(description = "User waits for sometime")
public void stepDefinitionMethodName() throws InterruptedException {
Thread.sleep(5000);
}
在执行测试时,我发现测试实际上经常被跳过,而且是随机的。以及失败的原因:
com.qmetry.qaf.automation.step.StepInvocationException:无法实例化 JavaStep:[]
Eclipse/TestNG Report 不显示除此之外的任何内容。
Appium 日志这样说:
[调试] [XCUITest] 检查应用程序'/var/folders/_j/9fbrggk96v3b44hlbshdp9tm0000gn/T/2020219-5328-duszjq.92kdd/Payload/.app' 是否实际存在于文件系统上[错误] [XCUITest] 错误:连接是拒绝端口 51487 [错误] [XCUITest] 在 Usbmux.connect (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-ios-device/lib/usbmux/index.js:183:13) [信息] [DevCon Factory] 在任何端口号上释放 202bc3b5a4c4571e98c08785b278002c7deed0f3 设备的连接 [info] [DevCon Factory] 没有找到缓存的连接 [debug] [BaseDriver] 事件 'newSessionStarted' 记录在 1584634979919 (21:52:59 GMT+0530 ( IST)) [debug] [W3C] Encountered internal error running command: Error: Connection was denied to port 51487 [debug] [W3C] at Usbmux.connect (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-ios-device/lib/usbmux/index.js:183:13) [info] [HTTP] <-- POST /wd/hub/session 500 40513 ms - 702
在下一次运行中,同样的测试可能会通过。
查看步骤实现,它非常简单,因为它使用 thread.sleep 等待 5 秒。我想不出这个测试步骤应该抛出上述错误的任何原因。
上述步骤来自以下场景。我删除了上述步骤并重新执行了测试。它再次失败,如下所示:
#SRS-HLP-001-001
SCENARIO: <description>
META-DATA: {"author":"<XXX>","description":"SRS-HLP-001-001", "fullReset":true ,groups:[ "EXISTING_USER" , "IOS" , "ANROID" , "REGRESSION_1" , "HELP" ]}
Given User accepts Alert box if any
And Verify user is navigated to home screen, else login with "${login.user_name}" and "${login.password}"
And User accepts Alert box if any
Then Verify main Help screen will be displayed Help tab is clicked
END
@QAFTestStep(description = "User accepts Alert box if any")
public void acceptAlerts() throws InterruptedException {
handleBTPermissionAlert();
handlePNSPermissionAlert();
}
这是eclipse中的错误:
com.qmetry.qaf.automation.step.StepInvocationException:无法实例化 JavaStep:acceptAlerts[]
这是侦听器的详细信息:
<test enabled="true" name="Help">
<parameter name="env.resources"
value="resources/data;resources/ios" />
<parameter name="step.provider.pkg"
value="qaf.<xxx>.tests;qaf.<xxx>.steps;qaf.<xxx>.ios.steps" />
<parameter name="appium.capabilities.app"
value="<path to the app>" />
<parameter name="scenario.file.loc" value="scenarios/Help.bdd" />
<classes>
<class>
name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory" />
</classes>
</test>
这是使用的 ivy.xml。
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="com.qmetry" module="QAF" status="integration">
</info>
<dependencies>
<dependency org="com.qmetry" name="qaf" rev="2.1.15" force="true"/>
<dependency org="com.qmetry" name="qaf-support" rev="2.1.13" />
<dependency org="com.qmetry" name="qaf-support-ws" rev="2.1.15" />
<dependency org="org.aspectj" name="aspectjtools" rev="1.9.5"/>
<dependency org="org.aspectj" name="aspectjweaver" rev="1.9.5" />
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3"/>
<dependency org="io.appium" name="java-client" rev="7.3.0"/>
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="3.141.59" force="true"/>
</dependencies>
</ivy-module>
需要有关如何确保测试用例不被频繁跳过的帮助。