英语单词

Instrument 对APP进行性能优化

推荐访问: 如何使用Xcode7的Instruments 检测解决iOS内存泄露?如何利用Xcode的instrument中的Automation实现自动化测试

      Instrument 对APP进行性能优化,你如果有点开发经验,那么通过这句话问:“平时你是怎么测试你APP的?”。

      有一定的开发经验的人在项目中,都会使用到一些测试工具。比如常见的UIAutomation。android4.3也引入的automation新框架,嗯,这工具确实不简单呢。下面的是apple的官网 ,使用的测试都是自动化脚本啊!下面是apple官网的一个解释和小例子:
      In essence, your test script is an ordered set of commands, each of which accesses a user interface element in your app to perform a user action on it or to use the information associated within it. All the user interface elements in your app are represented to the script through an ordered hierarchy of objects defined by the UIAElement
      class and its subclasses. To reach a specified UI element, the script simply calls down the element hierarchy, starting with the top-level target object obtained by calling UIATarget.localTarget()
       For example, the first button in the main window of your app might be referenced by index as follows

      大概意思就是:测试脚本是指令的有序集合,其中每次访问一个用户界面元素它就会执行相对应的脚本。所有的用户界面元素都是脚本通过有序的层次结构定义的对象,也就是UIAElement类 和它的子类。要想获取到对应的UI元素,你可以使用脚本简单地调用元素层次结构,从顶层目标对象通过调用UIATarget.localTarget()。例如,diyi个按钮在主窗口的应用程序可能会引用的索引,如下所示

UIATarget.localTarget().frontMostApp().mainWindow().buttons()[0]

      要想看懂脚本需要一点JavaScript语言基础,这个脚本咋看起来有点类似swiftly的,有木有啊!

通过官方文档可以看出,它的测试脚本都是以 UIATargt开头,因为这是根元素。然后,后面跟着localTarget

其实也很简单,xcode中自带的Instuments工具可以用来进行APP的自动化测试。好,下面,我们直接看演示吧!UI Automation它所支持的脚本语言除了自己原生的swift语言外,还支持JavaScript语言

      下面看看界面吧!
      打开位置:

11.png

打开位置.png

      界面:

22.png

老Xcode的

 

      选这想要测试的工具,各显神通,根据不同需求测试:

33.png

添加使用工具.png

      点击Z下面的红色按钮,就是录制你的操作,并生成脚本。接下来就可以随意修改脚本以供以后测试了。(前提是要学点JS,或去Apple官网看教程)

44.png 

脚本

      这个是检测内存是否被泄漏了:

55.png 

检测内存泄漏


2017-07-07浏览次数:1368次
本文来源:https://m.yiqi.com/retiao/detail_31.html
热门标签: 如何用Instruments 检验app
分享到
上一篇:instrument 内存管理工具是xcode中比较好的内存管理
下一篇:instrument解释及几种用法
最新资讯
看过该文章的人还看过
利用Instrument对APP进行性能优化
Instrument对APP性能优化方式
如何Instrument对APP进行性能优化