AppCrawler【求助】断言失败,但报告显示通过问题


实际测试用例断言失败,但为什么报告显示是通过的?
下面是配置文件:

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: "2021121301"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 60
maxDepth: 10
capability:
  noReset: "true"
  fullReset: "false"
  appium: "http://127.0.0.1:4723/wd/hub"
  appPackage: "com.cha.buyer"
  appActivity: "com.cha.buyer.ui.MainActivity"
testcase:
  name: "buyer_new AppCrawler"
  steps:
  - given: []
    when: {xpath: "//*[@text = '我的']",action: click}
    then: ["//*[contains(@text, '郭雨6585')]","//*[contains(@text, '充值')]"]
  - given: []
    when: {xpath: "//*[@text = '首页']",action: click}
    then: ["//*[contains(@text, '精品')]"]
  - given: []
    when: {xpath: "//*[@text = '我的']",action: click}
    then: []
    
selectedList:
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Button')]"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Text') and @clickable='true' and string-length(@text)<10]"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[@clickable='true']/*[contains(name(), 'Text') and string-length(@text)<10]"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Image') and @clickable='true']"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[@clickable='true']/*[contains(name(), 'Image')]"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Image') and @name!='']"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Text') and @name!='' and string-length(@label)<10]"
  action: null
  actions: []
  times: 0
firstList: []
lastList:
- given: []
  when: null
  then: []
  xpath: "//*[@selected='true']/..//*"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//*[@selected='true']/../..//*"
  action: null
  actions: []
  times: 0
backButton:
- given: []
  when: null
  then: []
  xpath: "Navigate up"
  action: null
  actions: []
  times: 0
triggerActions:
- given: []
  when: null
  then: []
  xpath: "share_comment_guide_btn"
  action: null
  actions: []
  times: 0
xpathAttributes:
- "class"
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
blackList:
- given: []
  when: null
  then: []
  xpath: ".*[0-9]{2}.*"
  action: null
  actions: []
  times: 0
beforeRestart: []
beforeElement:
- given: []
  when: null
  then: []
  xpath: "/*"
  action: "Thread.sleep(500)"
  actions: []
  times: 0
afterElement: []
afterPage: []
afterPageMax: 2
tagLimitMax: 2
tagLimit:
- given: []
  when: null
  then: []
  xpath: ""
  action: null
  actions: []
  times: 1000
- given: []
  when: null
  then: []
  xpath: ""
  action: null
  actions: []
  times: 1000
- given: []
  when: null
  then: []
  xpath: "share_comment_guide_btn_name"
  action: null
  actions: []
  times: 1000
assertGlobal: []```

你都没写断言,哪来失败。。。你看到的失败,可能只是没找到对应的控件吧


这里不是断言么?这个then是怎么用的,以及断言怎么写呢,大佬有没有相关帖子让我们学习下,搜全网好像都没有介绍断言的 :sweat_smile:

没注意到你这块。。
断言因为用的少,所以文档里没怎么提到。

最近打算重构断言部分,之前写的太简单了。你可以贴下appcawler.log

1 个赞

appcrawler.log (1.9 MB)
那大佬,这个断言assertGlobal: 怎么来写呢,现在是能跑起来,但不知道怎么写断言,不知道什么情况是失败的,应用场景是什么,想在项目中推广下

1 个赞

这个地方是全局断言,通常是断言有没有error或者异常关键字。用法是

assertGlobal:
  - then:
    - //*[contains(@text, "undefined")]
    - //*[contains(@text, "error")]

大佬,这个使用后,全是失败的,显示
//[contains(@text, “undefined”)] 不存在
0 was not greater than 0 (in Checkpoint) at ScalaTestTemplate.scala:73
//
[contains(@text, “error”)] 不存在
0 was not greater than 0 (in Checkpoint) at ScalaTestTemplate.scala:73
我理解,这个断言的意思是指,元素中包含了undefined、error这个文字(text)的就会失败

我的yaml写法如下
image