Popularity
0.9
Declining
Activity
0.0
Stable
20
4
2

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.

Programming language: Swift
License: MIT License
Tags: Swift     Testing     UI Testing    

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.

Do you think we are missing an alternative of UI tests without UI Testing experiment or a related project?

Add another 'UI Testing' Library

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 disabled
  • app.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

  1. Sliders
  2. Text fields
  3. Gestures - swiping and scrolling
  4. Collection views
  5. Map views
  6. ...

Out of scope (for now)

  1. System alerts - this probably isn't be possible
  2. SwiftUI - ViewInspector is probably a better choice