Opening
Open Cnblog found himself for several years, not in the above update blog, these days in the collation of some information, found themselves using the instrument process of some of the documents and materials, data collation time should be last year, However, the use of instrument in iOS development is very helpful, I use the process has been using the management of multi-memory, instrument for me in the application of the problem solving a great help, written as a blog to record.
==============================================================
Automation
Knowledge of automated testing
Automated testing is the process of translating a man-driven test behavior into a machine execution. Typically, after a test case has been designed and reviewed, the tester performs the test step-by-stage according to the procedures described in the test case to obtain a comparison between the actual result and the desired result. In this process, in order to save manpower, time or hardware resources, improve testing efficiency, the introduction of the concept of automated testing (from Baidu Encyclopedia).
Automation is a framework for automating test execution on iphone device and iphone simulator, released with iOS 4.0 system
- UIAutomation Test Requirements:
Test the app source code, import the required script files, learn about JavaScript
- Instrument Automation use
- To import a test script:
- Open tested App Project
- ? +i Open Instrument
- Select Automation Template->profile
- ? +r Stop Profile
- On the left scripts select Add->import ...,
- Select the written test script (you wrote a script showuiaelenmenttree.js) scripts will have a script list
- Script contents can be seen in script list to the right
- ? +r performing Script tests
- You can see the script test log
Provides a record user action to generate a test script when operating on an interface, but automatically generates a test script without an assertion action
1: Open tested App Project
2:?+i Open Instrument
3: Choose Automation Template->profile
4:?+r Stop Profile
5: On the left scripts select Add->create ... If you see a new script file, you see 3 action buttons below the script code
6: Click the Red Record button, will launch the app, you are on the device or simulator operation will generate action code click the Square Stop Record button recording complete, after? +r stop
7: You need to replay the recording script again can click the Triangle button, or directly? +r perform test playback
-
- To write a test script:
By importing test scripts and recording scripts, you can familiarize yourself with some basic APIs
Next write a test script
1: Open tested App Project
2:?+i Open Instrument
3: Choose Automation Template->profile
4:?+r Stop Profile
5: On the left scripts select Add->create ... You will see a new script file generation script editable area for scripting such as 4 regions, where test cases are written in this area
6: Test Case writing
Code Demo: interface input TextField input length
var target = Uiatarget.localtarget ();
var app = Target.frontmostapp ();
var window = App.mainwindow ();
var textfields = Window.textfields ();
Check Number of Text field (s)
if (textfields.length!=1)
{
Uialogger.logfail ("Fail:inavlid Number of Text field (s)");
}
Else
{
Uialogger.logpass ("Pass:correct Number of Text field (s)");
}
Note
1: In the use of equipment for automated testing it is important to note that in the release configuration choose to use developer profile (not Ad-hoc distrubution profile). The default release profiling has been completed.
2: Documentation
UIAutomation JavaScript API Reference Documentation:
http://developer.apple.com/library/ios/#documentation/developertools/reference/uiautomationref/_index.html
Using instrument (a) in iOS development Automation