X Code 7 introduces a new UI testing feature for fully integrated
with X Code IDE. UI Testing, Recording and reporting are three major updates.
The core technologies are XCTest and Accessibility feature. It requires new OS
features iOS 9 and OS X 10.11 and Privacy protection for iOS devices enabled
for development and connected to a trust host running on XCode. OS X must grant
permissions to XCode helper for prompted on first run.
X Code is offering a target template that can target to be tested
“Cocoa Touch UI Testing Bundle (iOS)” and “Cocoa UI Testing bundle (OS X)”. This target can create an UI project under project source code and place the UI test cases into same project.
UI Recording 
               Interact with your app and generate
the code for new test cases and existing test cases. It will automatically find
UI elements with synthesizing your user events. 
       APIs
There are 3 new classes in this release.
XCUIApplciation
- Proxy for the tested Application and its run in a separate process
- Launching target app If any existing process is running, It will terminates any pre existing instance
- Its starting point for finding elements in the app
Example : Testing the Add
button
// Application 
let app
=  XCUIApplciation()
app.launch()
// Element and Query 
let addButton =
app.buttons["Add"]
addButton.tap()
// Assertion
XCTAssertEqual(app.tables.cells.count,1)
- Element Type: Button,
     Cell, Window, Etc. 
- Identifiers:
     Accessibility identifier, Label, Class, Etc. 
- Element hierarchy:
     Application is the root of tree elements. These elements can be used by
     queries with type of element and its identifiers.
- Element uniqueness:
     Every XCUIElement is backed by a query and every query must resolve
     exactly one match like as XPath. If it matches multiple matches then
     it cause the test failure. This can be found by using exists
     property.
- Event synthesis: It
     will simulate user interactions on elements. All APIs are
     platform-specific.   
For OS X:button.click();
For iOS : button.tap();  
For iOS and OS X textField.typeText("Hello
World"); 
XCUIElementQuery
- This API can help us for specifying elements and Queries work based on relationships and filtering. Expressing relationships by Descendants, Children and containment.
- Filtering can be done by
                                      Element Type:
Button, Table, Menu, etc.
                                       Identifiers: Accessibility
identifier, label, title, etc.
                                       Predicates:
Value, Partial matching and others
                   Combining relationships and Filtering 
descendantsMatchingType()
childrenMatchingType()
containingType()
                   allButtons = app.descendantsMatchingType(.Button)
                   childButtons =
navBar.childrenMatchingType(.Button)
                          allCellsInTable
= table.descendantsMatchingType(.Cell)
                   cellQuery = cells.containingType(.StaticText,
identifier:”Groceries”) 
Test case results
            Show results for all tests
            Pass/fail
            Failure reason Performance metrics





 
 


