[appium学习笔记]writing maintainable UI test automation

what defines a high quality test?

​​​​​​​
1.only fails when the SUT fails
2.easy to read
3.fast and reliable

what defines mantainability of tests?

  1. changes are not frequently needed
  2. changes are easy to apply
  3. changes to SUT don’t break your test scenario
  4. if a change to the SUT breaks a test, it has no butterfly effect on all the tests(each test only tests one specific attribute of the SUT)

how to minimize the impact of change?

  1. use stable control locator strategy​​​​​​​
    • Accessibility id
      • iOS: accessibility id
      • android: content-description
      • windows: AutomationId
    • XPath: stop using XPath! It is extremely fragile!
    • UI Test Recorders: don’t use them, they generate very fragile tests
  2. minimize repetition of code
  3. minimize the things tested by one test case
  4. create abstraction bewteen the test and the SUT

patterns & practices for maintainability

  1. don’t repeat yourself(DRY)
    • stop copiying and pasting code, avoid repeating patterns that we use over and over again, move them either to a class or a method)
  2. single responsibility principle
    • when you write a class, then this class should only be responsible for one thing only
  3. page object pattern
    • for each screen/page create a class that abstracts the interaction with the screen/page
    • for each action create an action method that returns a page object
    • for each verification create a method that executes the verification and returns true or false
  4. descriptive and meaningful phrases(DAMP)
    • read the code as if it is a sentence
      在这里插入图片描述

SOLID priciple

S: single responsibility principle
O: open/close principle(create a base class in such a way that when you inherit from the base class, your class is open for extensibility but close for modification by the inheriting class)
L: liskov substitution principle(objects in a program should be replaceable with instances of their subtypes without altering the correctness of the program)
I: interace segregation principle(create specific interfaces that get implemented by concrete classes)
D: dependency inversion principle(you should only depend on abstractions -the interfaces, instead of the concrete implementations)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值