Description
This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-level than XCTest but not as heavy handed (or slow and brittle) as UI Testing.
The general idea is to provide an API similar to UI Testing but be able to spin up any controller on the fly. By putting the controller inside of a window the test behaves a bit more like the real app.
This extends on my thoughts in a recent blog, Testing the UI without UI Testing in Swift.
UI tests without UI Testing experiment alternatives and similar libraries
Based on the "UI Testing" category.
Alternatively, view UI tests without UI Testing experiment alternatives based on common mentions on social networks and blogs.
-
Bluepill
Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine -
TouchVisualizer
DISCONTINUED. Lightweight touch visualization library in Swift. A single line of code and visualize your touches! -
ios-driver
Selenium server to test native, hybrid and web apps on IOS. Join us on IRC #ios-driver on freenode -
AutoMate
Swift framework containing a set of helpful XCTest extensions for writing UI automation tests -
appium
Appium is an open source test automation framework for use with native and hybrid mobile apps. -
UIAutomation
JavaScript library to write test scripts that exercise your app’s user interface elements while the app runs on a connected device. -
Flawless App
tool for visual quality check of mobile app in a real-time. It compares initial design with the actual implementation right inside iOS simulator.
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of UI tests without UI Testing experiment or a related project?
README
UI tests without UI Testing experiment
This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-level than XCTest but not as heavy handed (or slow and brittle) as UI Testing.
The general idea is to provide an API similar to UI Testing but be able to spin up any controller on the fly. By putting the controller inside of a window the test behaves a bit more like the real app.
This extends on my thoughts in a recent blog, Testing the UI without UI Testing in Swift.
Is this crazy?
Probably! But maybe this is something worth exploring.
Have you tried anything like this? Is this obviously a maintenance nightmare? I would love to hear what you think.
Setup
In your XCTestCase
tests...
continueAfterFailure = false
let app = App()
let controller = /* your controller */
app.load(controller: controller)
// ...
See the unit tests for more examples.
View finders
UILabel
label(text:)
- find a non-hidden label with the given text
, recursively, in the view
UIButton
button(title:)
- find a non-hidden button with the given title
, recursively, in the view
UISwitch
switch(accessibilityLabel:)
- find a non-hidden switch with the given accessibilityLabel
, recursively, in the view
UIStepper
stepper(accessibilityLabel:)
- finds a non-hidden stepper with the given accessibilityLabel
, recursively, in the view
UITableView
app.cell(containingText: "Cell text")
- finds the first UITableViewCell
(or subclass) containing a label matching the text
Interactions
tap()
button.tap()
- triggers the target-action for the button if not disabled
toggle()
switch.toggle()
- triggers the value changed action on the switch if not disabled
tapCell(containingText:)
app.tapCell(containingText: "Cell text")
- taps the found cell (above) via its index path and delegate
incrementStepper()
and decrementStepper()
app.incrementStepper(accessibilityLabel:)
- increments the stepper by the step value and triggers the value changed action, if not disabledapp.decrementStepper(accessibilityLabel:)
- decrements the stepper by the step value and triggers the value changed action, if not disabled
View controllers
Pushing/popping and presenting/dismissing view controllers is supported.
UIAlertController
app.alertViewController.tapButton(title: "Dismiss")
- triggers the attached action and dismisses the alert
To-do
- Sliders
- Text fields
- Gestures - swiping and scrolling
- Collection views
- Map views
- ...
Out of scope (for now)
- System alerts - this probably isn't be possible
- SwiftUI - ViewInspector is probably a better choice