Skip to content

xamarin-automation-service/xcuitest-pop-example

Repository files navigation

XCUITest POP example

This project demonstrates how to use Apple's XCUITest and is based on the the page object pattern example.

Requirements

  • Xcode 8
  • CocoaPods Dependency Manager
  • XTC CLI Tool

Running these tests locally

  1. Clone this repo
  2. Navigate to the folder in terminal and run pod install*
  3. Open the ToDoList.xcworkspace file using Xcode.
  4. Build
  5. 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.

XCUITest Implementation

  1. ToDoListUITests Group has the following structure to keep the files organized :

  2. BaseTest inherits XCTestCase which has the setUp() and tearDown() methods required to run tests. All tests inherit this base class.

  3. BasePage contains shared/helper methods needed by Pages. It also has the assertOnPage() which checks for the page trait and takes a screenshot for that page. There is a helper method implemented called waitForElement(). All pages inherit this base class.

  4. Pages are structured as :

    • Queries for Page Elements defined at the top as type XCUIElement
    • Page Constructor init() passes the Page Trait to Base as super.init(trait: <traitValue>) and initializes Page Element queries
    • Page Methods for that page defined at the bottom
  5. Tests are structured as :

    • Test Method names must start with test
  6. Follow the page object pattern to build pages and write tests that interact with your app.

Troubleshoot

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 the ToDoList.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.

Upload tests to Xamrin Test Cloud

  • Follow these instructions to prepare your tests for Test Cloud.
    • This example has already been prepared and uses the VSMobileCenterExtensions.framework via Cocoapods.
  • 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

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published