This project demonstrates how to use Apple's XCUITest and is based on the the page object pattern example.
- Xcode 8
- CocoaPods Dependency Manager
- XTC CLI Tool
- Clone this repo
- Navigate to the folder in terminal and run
pod install
* - Open the
ToDoList.xcworkspace
file using Xcode. - Build
- Navigate to the Test Navigator in Xcode and Run Tests
*This project uses CocoaPods to manage an Extension. If you do not have the CocoaPods dependency manager installed, you can do it from here before running the command.
-
ToDoListUITests Group has the following structure to keep the files organized :
- BaseTest.swift
- BasePage.swift
- Pages Group
- Tests Group
-
BaseTest
inherits XCTestCase which has thesetUp()
andtearDown()
methods required to run tests. All tests inherit this base class. -
BasePage
contains shared/helper methods needed by Pages. It also has theassertOnPage()
which checks for the page trait and takes a screenshot for that page. There is a helper method implemented calledwaitForElement()
. All pages inherit this base class. -
Pages are structured as :
- Queries for Page Elements defined at the top as type
XCUIElement
- Page Constructor
init()
passes the Page Trait to Base assuper.init(trait: <traitValue>)
and initializes Page Element queries - Page Methods for that page defined at the bottom
- Queries for Page Elements defined at the top as type
-
Tests are structured as :
- Test Method names must start with
test
- Test Method names must start with
-
Follow the page object pattern to build pages and write tests that interact with your app.
If there are build errors when you initially clone the repo, try the following :
- Make sure you have opened the
ToDoList.xcworkspace
file and not theToDoList.xcodeproj
- Make sure the Pods folder exists and visible in your workspace
- Add the
VSMobileCenterExtension Pod
to the Scheme. Select the Pod and build it, switch back to the app and build again.
- Follow these instructions to prepare your tests for Test Cloud.
- This example has already been prepared and uses the
VSMobileCenterExtensions.framework
via Cocoapods.
- This example has already been prepared and uses the
- Go to Test Cloud and start a new test run
- Go through the wizard and then select XCUITest on the last step
- Follow the provided instructions to install the CLI and uplaod your tests