iOS UI Automation Test Framework

Last update: May 16, 2022

Deprecation: EarlGrey 1.0 is deprecated in favor of EarlGrey 2.0 which integrates it with XCUITest. Please look at the earlgrey2 branch. EarlGrey 1.0 is not being maintained internally with iOS 13.

EarlGrey

Apache License CC-BY 4.0 License Build Status Carthage compatible CocoaPods Gem Version

For EarlGrey 2, please go to earlgrey2 branch.

EarlGrey is a native iOS UI automation test framework that enables you to write clear, concise tests.

With the EarlGrey framework, you have access to enhanced synchronization features. EarlGrey automatically synchronizes with the UI, network requests, and various queues; but still allows you to manually implement customized timings, if needed.

EarlGrey’s synchronization features help to ensure that the UI is in a steady state before actions are performed. This greatly increases test stability and makes tests highly repeatable.

EarlGrey works in conjunction with the XCTest framework and integrates with Xcode’s Test Navigator so you can run tests directly from Xcode or the command line (using xcodebuild).

Getting Started

The EarlGrey documentation for users is located in the EarlGrey/docs folder. To get started, review the EarlGrey features, check for backward compatibility, and then install/run EarlGrey with your test target. After everything is configured, take a look at the EarlGrey API and start writing your own tests.

Getting Help

If you need help, several resources are available. First check the FAQ. If you have more questions after reading the FAQ, see Known Issues. You can bring more specific issues to our attention by asking them on stackoverflow.com using the #earlgrey tag. You can also start new discussions with us on our Google group or request to join our slack channel.

Analytics

To prioritize and improve EarlGrey, the framework collects usage data and uploads it to Google Analytics. More specifically, the framework collects the MD5 hash of Bundle ID, Test Class Names and Test Method Names. This information allows us to measure the volume of usage. For more detailed information about our analytics collection, please peruse the GREYAnalytics.m file which contains the implementation details. If they wish, users can choose to opt out by disabling the Analytics config setting in their test’s - (void)setUp method:

In Objective-C:

// Disable analytics.
[[GREYConfiguration sharedInstance] setValue:@(NO) forConfigKey:kGREYConfigKeyAnalyticsEnabled];

In Swift:

// Disable analytics.
GREYConfiguration.sharedInstance().setValue(false, forConfigKey: kGREYConfigKeyAnalyticsEnabled)

For Contributors

Please make sure you’ve followed the guidelines in CONTRIBUTING.md before making any contributions.

Setup an EarlGrey Project

  1. Clone the EarlGrey repository from GitHub:
git clone https://github.com/google/EarlGrey.git
  1. After you have cloned the EarlGrey repository, download all the dependencies using setup-earlgrey.sh.
  2. After the script completes successfully, open EarlGrey.xcodeproj and ensure that all the targets build.
  3. You can now use EarlGrey.xcodeproj to make changes to the framework.

Add and Run Tests

Unit Tests

To add unit tests for EarlGrey, use UnitTests.xcodeproj located at Tests/UnitTests. To run all unit tests, select the UnitTests Scheme and press Cmd+U.

Functional Tests

To add functional tests for EarlGrey, use the FunctionalTests.xcodeproj located at Tests/FunctionalTests. To run all functional tests, select the FunctionalTests Scheme and press Cmd+U.

GitHub

https://github.com/google/EarlGrey
Comments
  • 1. Add Support for Device Shake API

    Implements #678. Added a functional test to test device shake.

    Note that at the time of cloning the project, numerous unit tests are broken and do not pass on iOS 11.)

    Reviewed by LeoNatan at 2018-02-05 18:09
  • 2. EarlGrey gem

    Fix #73

    The gem is still a work in progress. Carthage support is verified as working.

    Todo

    • [x] Write RSpec test
    • [x] Fix Ruby warnings
    • [x] Fix rubocop violations

    After merge

    • [x] More RSpec tests
    • [x] Run Ruby tests on Travis CI
    • [ ] Setup coveralls
    • [ ] Setup code climate -- works
    • [x] Research Gemnasium -- not supported
    • [ ] Update example to support carthage
    • [ ] Update cocoapods Podfile to use the gem
    • [ ] Update documentation to recommend using the gem

    Let me know what emails to add on RubyGems. Once added as a gem owner, you'll be able to make gem releases (rake release).

    Reviewed by bootstraponline at 2016-04-20 22:42
  • 3. EarlGrey 2.0 | Cocoapods | Can't run target app without UITests

    Target app crashes on start if run alone (without UITests ex. by hitting cmd+R) and get

    Fatal failure: EarlGrey's app component has been launched without edoPort assigned. You are probably running the application under test by itself, which does not work since the embedded EarlGrey component needs its test counterpart present. in /Users/brettfazio/dev/reducingimports/EarlGrey/AppFramework/DistantObject/GREYHostApplicationDistantObject.m:93

    It can be reproduce in Example from earlgrey2 branch.

    Xcode 10.2.1 Swift 5.0 Cocoapods 1.6.1

    Reviewed by konrad-zdunczyk-luxmed at 2019-07-11 15:58
  • 4. `tap()` Action fails although target item exists

    i keep getting Reason: Action 'Tap' failed for tapping a UIButton subclass although target UIButton with the correct accessibilityId / accessibilityLabel exists and logged in window hierarchy dump after failure.

    Runs on iPhone5 simulator, iOS 10.2 , EarlGrey V1.3.0

    Reviewed by haitham-reda at 2017-01-23 15:27
  • 5. EarlGrey 2.0 Helper Bundle (Swift) can't find XCTest.h

    I set up EarlGrey 2.0 according to setup.md.

    In Helper Bundle Section, I added Bridging-Header for Helper Bundle, then I got compile error. Error message is 'XCTest/XCTest.h' file not found in XCTestCase+GREYSystemAlertHandler.h.

    How can i resolve this issue.

    I tried to find what is different to FunctionalTests HostDOCategoriesSwift with my bundle.

    • Build Settings
      • Always Embed Swift Standard Libraries
        • FunctionalTests is Yes
      • Enable Bitcode
        • FunctionalTests is No

    I fix these, but i can't resolve the issue...

    Reviewed by jn000 at 2018-10-04 11:02
  • 6. Updating podspec to build pod from source

    Right now while integrating the pod into a project the only the framework gets downloaded, this makes it difficult to debug and find problems. Plus it also becomes difficult to use a custom version in your fork.

    Note: pod lib lint fails because the value of HEADER_SEARCH_PATHS is incorrect for development pods, a problem with CocoaPods while using development pod see CocoaPods issue

    Reviewed by tapthaker at 2016-06-08 17:34
  • 7. grey_replaceText() add UITextViewNotification

    add testReplaceTextOnUITextViewNotificationsPosted last request #642 force push ,so I can reopen it. Here is a new request. Sorry for that. @khandpur

    Reviewed by AzraelWang at 2017-10-18 06:47
  • 8. Fix TrustKit swizzling issues in Earl Grey

    As explained in #709, there is an issue with Earl Grey swizzling and proxy objects. This PR fixes specifically one of these issues when TrustKit is integrated in the host project and swizzles in TrustKit are enabled.

    The solution is to attempt getting the forwarding target class, if any, or use the actual class of the delegate as before.

    Reviewed by LeoNatan at 2018-05-22 13:23
  • 9. Fix all EarlGrey projects for Swift 3.0

    Fixes https://github.com/google/EarlGrey/issues/292.

    This is only done to fix the extant EarlGrey projects. As you can see, the EarlGrey syntax seems quite off. For this purpose, we plan to add a newer version of EarlGrey.swift that suits the Swift nomenclature better and tries to remove any unneeded wrappers.

    Reviewed by tirodkar at 2016-10-11 03:54
  • 10. Add earlgrey_gem.yml & Fix rubocop

    Update Ruby version requirement to 2.1 (Rubocop dropped 2.0). Both 2.0 and 2.1 are end of life Ruby versions.

    • https://www.ruby-lang.org/en/downloads/

    Fix #668

    Reviewed by bootstraponline at 2018-01-12 00:26
  • 11. Backport iOS 14 fixes to EarlGrey v1

    This PR backports all the issues described in https://github.com/google/EarlGrey/issues/1357 to EarlGrey v1. Where possible I've cherry-picked the original commit:

    • XCTestCase::recordIssue support: https://github.com/google/EarlGrey/pull/1377
    • UITouch private API changes (based on @steipe approach published in https://github.com/google/EarlGrey/issues/1357)
    • Disable caret blink animation: https://github.com/google/EarlGrey/pull/1404/

    Additionally I've also backported/fixed other small issues:

    • Duplicate TextField id's: https://github.com/google/EarlGrey/pull/1391/
    • Remove duplicated/invalid file references from Build Phase
    • Explicitly remove support for arm64 simulator (Apple Silicon) (not supported by ochamcrest)
    • Configure indentation to match existing guidelines
    • Fix deprecated developmentRegion
    • Fix weird documentation error due to an escaped character

    Let me know if you want to add/remove/split anything.

    (I've signed the CLA)

    Reviewed by xavierjurado at 2020-09-01 18:09
  • 12. Can I get an invite to slack?

    The slack and google groups are still set to private, and it's not possible to join without an invite.

    If possible, I'd like to get an invite email: base64. bXN0YXJqYWNAZ21haWwuY29t

    Reviewed by Megubit at 2022-05-12 09:30
  • 13. Crashing on iOS 15 with CocoaPods 2.2.1

    Issue

    Crashing during start on iOS 15 with cocoapids integration.

    Reproduce on EarlGreyExample App

    EarlGreyExampleSwift[90560:9922933] Crash handler setup completed.
    (lldb)
    

    Podfile

    target 'EarlGreyExampleSwift' do
      pod 'EarlGreyApp'
    end
    
    target 'EarlGreyExampleUITests' do
      pod 'EarlGreyTest'
    end
    
    target 'EarlGreyExampleSwiftUITests' do
      pod 'EarlGreyTest'
    end
    

    System

    macOS Monterey - 12.3.1
    xCode - Version 13.2.1
    iOS Simulator - 15
    

    Can be duplicate of https://github.com/google/EarlGrey/issues/1647

    Reviewed by sergius-la at 2022-05-11 03:58
  • 14. 'eDistantObject/EDORemoteVariable.h' file not found

    #import "AppFramework/Action/GREYActions.h" ^ /Users/yongjuwa/Desktop/cbdmobile/ios/../../shared/Earlgrey/AppFramework/Action/GREYActions.h:23:9: error: 'eDistantObject/EDORemoteVariable.h' file not found #import <eDistantObject/EDORemoteVariable.h> ^ 1 error generated. :0: error: failed to emit precompiled header '/Users/yongjuwa/Library/Developer/Xcode/DerivedData/CBDMobile-gfssoqseupovomajrakqibbecrgu/Build/Intermediates.noindex/PrecompiledHeaders/EG2Header-swift_57OHYXJF0H8J-clang_219ISBKZ2L257.pch' for bridging header '/Users/yongjuwa/Desktop/cbdmobile/ios/CBDMobileUITests/EG2Header.h' /Users/yongjuwa/Desktop/cbdmobile/ios/CBDMobileUITests/EG2Header.h:3:9: note: in file included from /Users/yongjuwa/Desktop/cbdmobile/ios/CBDMobileUITests/EG2Header.h:3: #import "AppFramework/Action/GREYActions.h" ^ 2 errors generated.

    Reviewed by yongjun-python at 2022-04-26 08:21
  • 15. Unable to run sample tests

    I'm trying to get the sample project tests running, but I'm encountering some issues. I'm still fairly new when it comes to UI tests, so I'm not sure if I'm doing something wrong.

    I followed the Running the Functional Tests guide. Now if I try to build and run the app on my device, it will run successfully, however, if I try to run any of the tests I get the following error:

    FunctionalTests-Runner[32129:1238658] Running tests...
    FunctionalTests-Runner[32129:1238658] The bundle “FunctionalTests.xctest” couldn’t be loaded. Try reinstalling the bundle.
    FunctionalTests-Runner[32129:1238658] (dlopen(/var/containers/Bundle/Application/FunctionalTests-Runner.app/PlugIns/FunctionalTests.xctest/FunctionalTests, 0x0109): tried: '/var/containers/Bundle/Application/FunctionalTests-Runner.app/PlugIns/FunctionalTests.xctest/FunctionalTests' (code signature in <F9225F...> '/private/var/containers/Bundle/Application/FunctionalTests-Runner.app/PlugIns/FunctionalTests.xctest/FunctionalTests' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.),
    '/private/var/containers/Bundle/Application/FunctionalTests-Runner.app/PlugIns/FunctionalTests.xctest/FunctionalTests' (code signature in <F9225F...> '/private/var/containers/Bundle/Application/FunctionalTests-Runner.app/PlugIns/FunctionalTests.xctest/FunctionalTests' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.))
    
    

    Some suggest enabling Hardened Runtime to fix this kind of error. But this will cause the profile signing to fail, since the FunctionalTestRig.entitlements has a hardcoded application-identifier which doesn't change for my own profile. This can be fixed by manually changing the value to correspond with Xcode generated provisioning profile value. And the signing will work again. but... that also results in the same error, so no progress there.

    I'm not sure if I'm making a beginner's mistake here, as I mentioned I'm new in this field, so if anyone could point me out what I'm doing wrong and how to fix this, I would really appreciate it.

    I'm using Xcode Version 13.2.1 My device is on iOS 15.4

    Reviewed by Megubit at 2022-04-01 10:17
  • 16. Link error for real device and crash for simulator

    Steps to reproduce:

    1. Create a new iOS project.
    2. Set up EarlGrey by this cocoapods guide
    3. Build and run for real device or simulator.

    Build error for real device on M1 Mac: Screenshot 2022-03-02 at 11 01 53 PM

    Build error for real device on Intel Mac: Screenshot 2022-03-02 at 10 57 11 PM

    Launch crash for simulator on M1 Mac: Screenshot 2022-03-02 at 11 05 12 PM

    Launch crash for simulator on Intel Mac: Screenshot 2022-03-02 at 10 56 23 PM

    M1 Mac: Mac version: Mac Monterey 12.2.1 Xcode: 13.2.1 Simulator: iPhone 13 pro max iOS 15.2

    Intel Mac: Mac version: Mac Monterey 12.1 Xcode: 13.2.1 Simulator: iPhone 13 pro max iOS 15.2

    Reviewed by 623637646 at 2022-03-02 15:09
Kfm-ios-test - Test online for iOS Developer position in Kimia Farma or PT. Buana Varia Komputama
Kfm-ios-test - Test online for iOS Developer position in Kimia Farma or PT. Buana Varia Komputama

kfm-ios-test Kimia Farma Mobile iOS Test Test online for iOS Developer position

Feb 23, 2022
Test-To-Do-List - Test To Do List with core data
Test-To-Do-List - Test To Do List with core data

test-To-Do-List This is my first pet project with core data Launch screen Main s

Feb 26, 2022
BDD Framework and test runner for Swift projects and playgrounds
BDD Framework and test runner for Swift projects and playgrounds

Spectre Special Executive for Command-line Test Running and Execution. A behavior-driven development (BDD) framework and test runner for Swift project

Apr 20, 2022
test ios UnitTest and UITest

github_actions Bundlerの導入 fastlaneやiOSパッケージマネージャであるCocoaPodsはRubyのライブラリ 開発チームで使用するバージョンを揃えるためにBundlerを導入する bundlerのインストール gem install bundler Gemfile

Nov 3, 2021
iOS Test Hasitha

Welcome to the Bidone iOS Coding Test! iOS Create a simple application with the list of orders from viewModel and display them in a list. When a user

Nov 12, 2021
iOS Test for Openbank by David Moreno Lora
iOS Test for Openbank by David Moreno Lora

MarvelMobileTest-iOS iOS Test for Openbank by David Moreno Lora Installation Clone the project and install the dependencies using pod install Once th

Nov 16, 2021
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.

MetovaTestKit is a collection of useful test helpers designed to ease the burden of writing tests for iOS applications. Requirements Installation Usag

Aug 29, 2021
Alef Dev Test iOS

AlefDev тестовое задание iOS Задача Разработайте экран, где человек может заполн

Feb 25, 2022
Rapptr iOS Test Jimin Kim

Hello! Your task is to use the provided project to create the iOS app displayed

Dec 22, 2021
Mooviely - Mooviely Basic App for IOS Test

Mooviely Mooviely Basic App for IOS Test. Anasayfa Bu sayfa açıldığında ekranın

Feb 13, 2022
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!

OHHTTPStubs OHHTTPStubs is a library designed to stub your network requests very easily. It can help you: test your apps with fake network data (stubb

May 21, 2022
The XCTest Project, A Swift core library for providing unit test support

XCTest The XCTest library is designed to provide a common framework for writing unit tests in Swift, for Swift packages and applications. This version

May 10, 2022
Test Library for Swift's Error Handling

CatchingFire CatchingFire is a Swift test framework, which helps making expectations against the error handling of your code. It provides for this pur

May 16, 2022
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD

Apress Source Code This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD by Gio Lodi (Apress, 2021). D

Apr 6, 2022
This is a simple test app getting data from network to practice a tad bit.

test This is a simple test app getting data from network to practice a tad bit. Start Nothing fancy, no CocoaPods, just clone and run! Architecture Ju

Oct 9, 2021
Test case project for mackolik

Mackolik - iOS Developer - Test Case Gökhan Mandacı 28 Oct 2021 I developed a two-page app and a general purpose drop down widget for the Mackolik Tes

Oct 28, 2021
This repo holds the code for Dubizzle & Bayut test App

DubizzleClassified This repo holds the code for Dubizzle & Bayut test App About App This is a simple app which basically fetches item list from the gi

Oct 30, 2021
Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods
Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods

iTunes Search Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods Features ?? Searching music albums by name

Oct 31, 2021
Test Technique pour LeBonCoin

Test Technique pour LeBonCoin Test Technique pour LeBonCoin Créer une application universelle (iPhone, iPad) en Swift. Celle-ci devra afficher une lis

Nov 3, 2021