惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

Peter Steinberger

OpenClaw, OpenAI and the future | Peter Steinberger Shipping at Inference-Speed | Peter Steinberger The Signature Flicker | Peter Steinberger Just Talk To It - the no-bs Way of Agentic Engineering | Peter Steinberger Claude Code Anonymous | Peter Steinberger Live Coding Session: Building Arena | Peter Steinberger My Current AI Dev Workflow | Peter Steinberger Essential Reading for Agentic Engineers - August 2025 | Peter Steinberger Just One More Prompt | Peter Steinberger Poltergeist: The Ghost That Keeps Your Builds Fresh | Peter Steinberger Don't read this Startup Slop | Peter Steinberger Essential Reading for Agentic Engineers - July 2025 | Peter Steinberger Self-Hosting AI Models After Claude's Usage Limits | Peter Steinberger Logging Privacy Shenanigans | Peter Steinberger VibeTunnel's first AI-anniversary | Peter Steinberger Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger Peekaboo 2.0 – Free the CLI from its MCP shackles | Peter Steinberger Command your Claude Code Army, Reloaded | Peter Steinberger Essential Reading for Agentic Engineers | Peter Steinberger Slot Machines for Programmers: How Peter Builds Apps 20x Faster with AI | Peter Steinberger My AI Workflow for Understanding Any Codebase | Peter Steinberger stats.store: Privacy-First Sparkle Analytics | Peter Steinberger Showing Settings from macOS Menu Bar Items: A 5-Hour Journey | Peter Steinberger VibeTunnel: Turn Any Browser into Your Mac's Terminal | Peter Steinberger Vibe Meter 2.0: Calculating Claude Code Usage with Token Counting | Peter Steinberger llm.codes: Make Apple Docs AI-Readable | Peter Steinberger Automatic Observation Tracking in UIKit and AppKit: The Feature Apple Forgot to Mention | Peter Steinberger Peekaboo MCP – lightning-fast macOS screenshots for AI agents | Peter Steinberger Migrating 700+ Tests to Swift Testing: A Real-World Experience | Peter Steinberger Commanding Your Claude Code Army | Peter Steinberger Code Signing and Notarization: Sparkle and Tears | Peter Steinberger Vibe Meter: Monitor Your AI Costs | Peter Steinberger Claude Code is My Computer | Peter Steinberger Stop Over-thinking AI Subscriptions | Peter Steinberger Introducing Demark: HTML in. MD out. Blink-fast. | Peter Steinberger The Future of Vibe Coding: Building with AI, Live and Unfiltered | Peter Steinberger MCP Best Practices | Peter Steinberger Finding My Spark Again | Peter Steinberger Top-Level Menu Visibility in SwiftUI for macOS | Peter Steinberger Fixing keyboardShortcut in SwiftUI | Peter Steinberger Supporting Both Tap and Long Press on a Button in SwiftUI | Peter Steinberger On Using Apple Silicon Mac Mini for Continuous Integration | Peter Steinberger Apple Silicon M1: A Developer's Perspective | Peter Steinberger Gardening Your Twitter: Curating Your Timeline | Peter Steinberger Gardening Your Twitter: Growing Your Followers | Peter Steinberger Forbidden Controls in Catalyst: Optimize Interface for Mac | Peter Steinberger Disabling Keyboard Avoidance in SwiftUI's UIHostingController | Peter Steinberger The State of SwiftUI | Peter Steinberger Logging in Swift | Peter Steinberger Building with Swift Trunk Development Snapshots | Peter Steinberger Calling Super at Runtime in Swift | Peter Steinberger zld — A Faster Version of Apple's Linker | Peter Steinberger How to Fix LLDB: Couldn't IRGen Expression | Peter Steinberger Updating macOS on a Hackintosh | Peter Steinberger InterposeKit — Elegant Swizzling in Swift | Peter Steinberger The Great Mac Catalyst Text Input Crash Hunt | Peter Steinberger Jailbreaking for iOS Developers | Peter Steinberger Network Kernel Core Dump | Peter Steinberger How to macOS Core Dump | Peter Steinberger Kernel Panics and Surprise boot-args | Peter Steinberger The LG UltraFine 5K, kernel_task, and Me | Peter Steinberger Let's Try This Again | Peter Steinberger How We Work at PSPDFKit | Peter Steinberger Swizzling in Swift | Peter Steinberger WWDC for First-Timers, 2019 Edition | Peter Steinberger Challenges of Adopting Drag and Drop | Peter Steinberger Marzipan: Porting iOS Apps to the Mac | Peter Steinberger How to Use Slack and Not Go Crazy | Peter Steinberger Hardcore Debugging - Heavy Weapons for Hard Bugs | Peter Steinberger Binary Frameworks in Swift | Peter Steinberger Even Swiftier Objective-C | Peter Steinberger The Case for Deprecating UITableView | Peter Steinberger Running tests with Clang Address Sanitizer | Peter Steinberger Hiring a distributed team | Peter Steinberger Writing Good Bug Reports | Peter Steinberger Real-time collaboration, Apple, and you | Peter Steinberger Converting Xcode Test Runs to JUnit, the Fast Way | Peter Steinberger Efficient iOS Version Checking | Peter Steinberger Investigating Thread Safety of UIImage | Peter Steinberger Swifty Objective-C | Peter Steinberger Running UI Tests on iOS With Ludicrous Speed | Peter Steinberger A Pragmatic Approach to Cross-Platform | Peter Steinberger Surprises with Swift Extensions | Peter Steinberger Using ccache for Fun and Profit | Peter Steinberger UITableViewController designated initializer woes | Peter Steinberger Researching ResearchKit | Peter Steinberger The curious case of rotation with multiple windows on iOS 8 | Peter Steinberger UIKit Debug Mode | Peter Steinberger Retrofitting containsString: on iOS 7 | Peter Steinberger A Story About Swizzling "the Right Way™" and Touch Forwarding | Peter Steinberger Hacking with Aspects | Peter Steinberger Fixing UITextView On iOS 7 | Peter Steinberger Fixing What Apple Doesn't | Peter Steinberger How To Inspect The View Hierarchy Of Third-Party Apps | Peter Steinberger Fixing UISearchDisplayController On iOS 7 | Peter Steinberger Smart Proxy Delegation | Peter Steinberger Adding Keyboard Shortcuts To UIAlertView | Peter Steinberger How To Center Content Within UIScrollView | Peter Steinberger UIAppearance for Custom Views | Peter Steinberger Hacking Block Support Into UIMenuItem | Peter Steinberger
UI testing on iOS, without busy waiting | Peter Steinberger
Peter Steinberger · 2016-09-29 · via Peter Steinberger

At PSPDFKit, we’ve been using KIF (“Keep It Functional”) since 2014 to test UI components. We wrote about our process in April 2016, and it’s time to revisit. KIF is a good and proven solution. It mostly synthesizes UITouch objects or related events and the app processes it just as if the user would tap. KIF is compiled into your app and can run in tandem with other XCTests. You can mix XCTAssert* calls and UI instructions.

KIF

The big problem is that KIF for us was very flaky. If the system was under high load, tests failed because the timeout wasn’t enough. The solution usually was increasing the timeouts, until we reached a point where UI tests alone were running over 30 minutes. Without compile times.

That’s where we said “no more” and spent a lot of time on fixing the problem. Our solution for “ludicrous speed” was a combination of increasing layer speed and busy waiting. Simply checking the condition every X milliseconds until it’s either true or the timeout hits. This made our tests both faster and more stable. It’s a pragmatic solution.

KIF was originally written by Square and is still pretty well maintained. There are some helpers for Swift available, however the matchers are inconsistent both in scope and naming and some macros are named very general, such as system which causes issues. It’s not a big deal and we have an internal fork that renamed that, but you’ll certainly feel that it’s an older project with a good bit of technical debt. There’ve been talks for fixing up much of that in a KIF 4 and it’s not impossible to improve.

History

Apple released tools for UI automation all the way back in iOS 4. It was called UIAutomation and integrated into… wait for it… Instruments, and you had to use JavaScript to write tests. It all sounded pretty amazing despite the rumors that it was written by an intern. However, it was really flaky and almost no one actually succeeded in building reliable tests on top of it - and the few who did had to build additional tooling around it. UIAutomation was deprecated in Xcode 7 and finally completely removed in Xcode 8, without a clear path to migrate. Moving tests to XCUI was not trivial, but given that almost nobody used UIAutomation, Apple did not bother to write a migrator. Facebook is a notable large exception which used UIAutomation as their WebDriver.

XCUI

With Xcode 7 Apple gave us API to app UI, that can be used from Objective-C and Swift. No more JavaScript. It’s also for iOS and macOS, where UIAutomation was iOS specific. XCUI is quite awesome and even can automatically record tests for you.

Tests in XCUI run in a separate process. This is good in a way that you’re testing closer to what you ship to your users and bad in the way that it makes it very hard to mock data or test model assumptions - which really is how we build almost all of our tests. And if you use workarounds that allow data mocking, you risk polluting your app with test data.

XCUI also didn’t solve the synchronization problem and the documentation recommends using func expectation(for predicate: NSPredicate, evaluatedWith object: Any, handler: XCPredicateExpectationHandler? = nil) -> XCTestExpectation.

The expectation periodically evaluates the predicate and also may use notifications or other events to optimistically re-evaluate.

This is similar to our PSPDFWaitForConditionWithTimeout helper that we use in KIF.

What else is out there?

We’re not talking about Appium which currently has some troubles, because their WebDriver used UIAutomator which has been removed in Xcode 8, so they can’t run tests with Xcode 8 yet, but replacements are in the works).

Other noticable mentions are Subliminal (discontinued) or Frank (abandoned). There’s also Calabash which is backed by Xamarin and open-source. Tests are written with Ruby and it uses a WebDriver (UIAutomator, now custom).

EarlGrey

EarlGrey has been open sourced by Google in February 2016 and you might think it’s quite a young project. However, of you look at the Initial Commit with over 20 KLOC you quickly see that this is not the case. Google has been using EarlGrey internally for years before they made the effort to clean it up and open source it. It’s largely inspired by Android’s Espresso, and that’s a good thing. We’re using Espresso heavily to test our Android SDK, and it’s one of the shining parts of the Android ecosystem. Espresso has some great features such as CSS selector matchers that eventually will trickle down to EarlGrey.

It’s somewhat similar to KIF, however it’s not timeout based but uses extensive synchronization, with means that you dont need explicit waits or sleeps. It’s matchers are much more extensive and consistent and it has better visibility checkers to only interact with elements that really are on the screen - catching bugs that the user might experience.

Enabling Clang’s Address Sanitizer is a known issue in EarlGrey. If you try it, you will get a crash like this one:

However, this is being worked on and it’s quite the read!

Both KIF and EarlGrey extensively use private API to inject touches, which can break on major iOS updates, as it did with iOS 8. One scary looking example is IOHIDEventCreateDigitizerFingerEvent, however even WebKit uses that in it’s test runner, so chances are high that this will keep working.

Demo Time

But don’t trust us - see for yourself! We have an open source project that compares KIF, XCUI and EarlGrey using a demo of PSPDFKit.

iOS-UI-Testing-Comparison

Further reading