An understated approach to iOS integration testing.

Related tags

Testing Subliminal
Overview

Subliminal

Build Status Gitter chat

Subliminal is a framework for writing iOS integration tests. Subliminal provides a familiar OCUnit/XCTest-like interface to Apple's UIAutomation framework, with tests written entirely in Objective-C. Subliminal also provides a powerful mechanism for your tests to manipulate your application directly.

[ FeaturesGetting StartedRequirementsUsageContinuous IntegrationContributingContactLicense ]

Features

Seamless Integration

Write your tests in Objective-C, and run them from Xcode. See rich-text logs and screenshots in Instruments. Use UIAutomation to simulate user interaction. Subliminal lets you use familiar tools, no dependencies required.

Full Control

By using UIAutomation, Subliminal can simulate almost any interaction--without resorting to private APIs. From navigating in-app purchase dialogs, to putting your app to sleep, Subliminal lets you simulate complex interaction like a user. And when you want to manipulate your app directly, Subliminal will help you do that too.

Scalable Tests

Define Objective-C methods to help set up and tear down tests. Leverage native support for continuous integration. Take confidence in Subliminal's complete documentation and full test coverage. Subliminal is the perfect foundation for your tests.

How to Get Started

Running the Example App

  1. Clone the Subliminal repo: git clone https://github.com/inkling/Subliminal.git.
  2. cd into the directory: cd Subliminal.
  3. If you haven't already, set up Subliminal: rake install.
  4. Open the Example project: open Example/SubliminalTest.xcodeproj.
  5. Switch to the "Integration Tests" scheme. You may also see a scheme called "Subliminal Integration tests"--make sure you choose "Integration Tests."
  6. Choose Product > Profile (⌘+I).
  7. Under the User Templates, choose Subliminal.

Installing Subliminal

For an installation walkthrough, refer to Subliminal's wiki.

Requirements

Subliminal supports projects built using Xcode 5.1 and iOS 7.x SDKs, and deployment targets running iOS 6.1 through 7.1.

For iOS 5.1 support, use Subliminal 1.1.0 (found in the Releases section or on CocoaPods). To test in the iOS 5.1 Simulator, you will need to run OS X 10.8 and manually add the iOS 5.1 Simulator to Xcode 5.1, as described here.

Usage

Subliminal is designed to be instantly familiar to users of OCUnit/XCTest. In Subliminal, subclasses of SLTest define tests as methods beginning with test. At run-time, Subliminal discovers and runs these tests.

Tests manipulate the user interface and can even manipulate the application directly. Here's what a sample test case looks like:

@implementation STLoginTest

- (void)testLogInSucceedsWithUsernameAndPassword {
	SLTextField *usernameField = [SLTextField elementWithAccessibilityLabel:@"username field"];
	SLTextField *passwordField = [SLTextField elementWithAccessibilityLabel:@"password field" isSecure:YES];
	SLElement *submitButton = [SLElement elementWithAccessibilityLabel:@"Submit"];
	SLElement *loginSpinner = [SLElement elementWithAccessibilityLabel:@"Logging in..."];
	
    NSString *username = @"Jeff", *password = @"foo";
    [usernameField setText:username];
    [passwordField setText:password];

    [submitButton tap];

	// wait for the login spinner to disappear
    SLAssertTrueWithTimeout([loginSpinner isInvalidOrInvisible], 
    						3.0, @"Log-in was not successful.");

    NSString *successMessage = [NSString stringWithFormat:@"Hello, %@!", username];
    SLAssertTrue([[SLElement elementWithAccessibilityLabel:successMessage] isValid], 
    			@"Log-in did not succeed.");
    
    // Check the internal state of the app.			
    SLAssertTrue(SLAskAppYesNo(isUserLoggedIn), @"User is not logged in.")
}

@end

For more information, see Subliminal's wiki.

Continuous Integration

Subliminal includes end-to-end CI support for building your project, running its tests on the appropriate simulator or device, and outputting results in a variety of formats.

For example scripts and guides to integrate with popular CI services like Travis and Jenkins, see Subliminal's wiki.

Comparison to Other Integration Test Frameworks

  • How is Subliminal different from other integration test frameworks?

    Most other integration test frameworks fall into two categories: entirely Objective-C based, or entirely UIAutomation-based.

    Frameworks that are entirely Objective-C based, like KIF, Frank, etc., must hack the application's touch-handling system, using private APIs, to simulate user interaction. There is thus no guarantee that they accurately simulate a user's input. Moreover, these frameworks can only simulate interaction with the application, as opposed to interaction with the device, other processes like in-app purchase alerts, etc.

    Frameworks that are entirely based on Apple's UIAutomation framework require cumbersome workflows--writing tests in JavaScript, in Instruments--which do not make use of the developer's existing toolchain. Moreover, they offer the developer no means of manipulating the application directly--it is a complete black box to a UIAutomation-based test.

    Only Subliminal combines the convenience of writing tests in Objective-C with the power of UIAutomation.

  • How is Subliminal different than UIAutomation?

    Besides the limitations of UIAutomation described above, it is extremely difficult to write UIAutomation tests. This is because UIAutomation requires that user interface elements be identified by their position within the "element hierarchy", like

    var cell = UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()["foo"];

    These references are not only difficult to read but are also difficult to write. To refer to any particular element, you have to describe its entire ancestry, while including only the views that UIAutomation deems necessary (images, yes; accessible elements, maybe; private UIWebView subviews, sure!).

    UIAutomation-based tests are not meant to be written, but to be "recorded" using Instruments. This forces dependence on Instruments, and makes the tests difficult to modify thereafter.

    Subliminal allows developers to identify elements by their properties, independent of their position in the element hierarchy:

    SLElement *fooCell = [SLElement elementWithAccessibilityLabel:@"foo"];

    Subliminal abstracts away the complexity of UIAutomation scripts to let developers focus on writing tests.

    Subliminal also fixes several bugs in UIAutomation and the instruments CLI tool, such as instruments' lack for true device support. And, last but not least, Subliminal rewrites instruments' output using human-friendly formatting and ANSI colors:

Contributing

Subliminal welcomes pull requests! Check out the contributing guidelines to learn how to set up Subliminal for development and how to make a successful pull request.

Credits

Created by Jeff Wear, made possible by Inkling, with help from:

and Subliminal's growing list of contributors.

Contact

If you'd like to chat, we hold "office hours" on Gitter 3-4pm Pacific Time, Tuesdays and Thursdays.

Lastly, you can follow Subliminal on Twitter for news and tips (@subliminaltest).

Copyright and License

Copyright 2013-2014 Inkling Systems, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Add Podspec

    Add Podspec

    In progress Podspec per #29.

    Everything should be working -- it's just testing and cleaning out unused files at this point.

    For things like the summary in the Podspec, I just copied from existing Subliminal materials without making an attempt to change things.

    opened by MaxGabriel 28
  • Revise Subliminal's documentation.

    Revise Subliminal's documentation.

    • [x] Migrate installation process to wiki page to slim the README

    EDIT: This issue used to talk about adding contributing guidelines but that was moved to #166.

    enhancement 
    opened by wearhere 11
  • Fix UITextView accessibility path when contained within a UITableViewCell

    Fix UITextView accessibility path when contained within a UITableViewCell

    In iOS7, having a UITextView within a UITableViewCell doesn't appear to work as expected. The fix appears to function as expected.

    I haven't fixed the second test case that I added, and clear current text doesn't appear to work on either iOS 6 or iOS 7. I'll be debugging this issue now.

    opened by justinseanmartin 10
  • Add CHANGELOG for 1.1

    Add CHANGELOG for 1.1

    Re: #167

    Cocoapods, who I stole this changelog format from, has people add their new additions to the Master section of the changelog as they make PRs. Technically, all these commits should still be under the Master section (since 1.1 isn't released), but I wanted to show the layout of the changelog.

    opened by MaxGabriel 10
  • Can Subliminal use the new -w flag to select a device using instruments?

    Can Subliminal use the new -w flag to select a device using instruments?

    I noticed in the Xcode 5.1 release notes that instruments now lets you specify a device:

    The instruments command-line tool now supports specifying the simulator SDK and device type using the -w flag. To see a list of the supported simulator configurations as well as attached devices, execute instruments -s devices in a Terminal window. (14996865)

    I know that Subliminal jumps through several hoops to achieve this right now—is this new feature sufficient to replace the disabling/enabling of other SDKs and such?

    This isn't really an issue per se as the current approach works for me—I just wanted to let you know about this if you hadn't seen it already.

    enhancement 
    opened by MaxGabriel 10
  • Add capturing screenshots to SLDevice

    Add capturing screenshots to SLDevice

    Hey I have to run but I saw Jeff was on so I thought I'd put this up (Not ready to merge -- no documentation).

    1. Any ideas on how to test screenshot functionality? Haven't thought about this too hard but presumably difficult.
    2. How to represent the Rect, Point, etc. objects in UIAutomation? For now I just made a function that takes a CGRect and turns it into the literal string used to make the Rect object. Probably at the least I should move this to like an SLGeometry class.
    opened by MaxGabriel 9
  • "WebKit Threading Violation" error on Xcode6 and iOS8

    I am trying to run subliminal test on Mavericks + Xcode6 beta4 and iOS8 and keep getting the "WebKit Threading Violation" below. (The same app runs fine with subliminal-test on Xcode 5 and iOS7 device/simulator.)

    Has anyone else encounter this issue?

    Successfully installed the application on the device.
    
    Relaunching tests...
    
    ERROR: 2014-07-31 12:49:51.686 instruments[43821:4703] WebKit Threading Violation - initial use of WebKit from a secondary thread.
    
    The target application appears to have died
    
    opened by hongkai 8
  • Allow SLAssert methods to be called from non SLTest subclass methods

    Allow SLAssert methods to be called from non SLTest subclass methods

    What do you think about this? I was planning on building a library of helper methods to build up the test cases, but unless they subclass SLTest, I can't call the assert methods. This doesn't seem right to me.

    This is my proposed solutions, but I wanted to get some thoughts.

    opened by justinseanmartin 8
  • TextField under ScrollView/TableView/TableCell not tappable

    TextField under ScrollView/TableView/TableCell not tappable

    Below is a hierarchy of elements that I've been trying to find but couldn't get it to work. To add more detail, the element seems to be "seen" by the isValidorVisible method; however is not "tappable" and gives the consequent failure.

    UIAWindow: name:UIWindow: 0x10bc37010 rect:{{0, 0}, {320, 568}}
    UIAScrollView: name:TPKeyboardAvoidingScrollView: 0x10bba1360 rect:{{0, 20}, {320, 568}}
    UIATableView: name:UITableView: 0x10d865200 value:rows 1 to 3 of 3 rect:{{1, 172}, {320, 132}}
    UIATableCell: name:UITextField: 0x10bb9b060 value: rect:{{1, 172}, {320, 44}}
    UIATextField: name:UITextField: 0x10bb9b060 value:User ID rect:{{21, 179}, {248, 30}}
    UIATextField: name:User ID value:User ID rect:{{21, 179}, {248, 30}}
    

    I've also created a sample application here: https://github.com/mrsamuelkim/Subliminal/tree/master/Simple%20App

    Help would be appreciated! Thanks.

    opened by ghost 8
  • Allow passing in pre-ordered arrays of tests to SLTestController

    Allow passing in pre-ordered arrays of tests to SLTestController

    I'm not sure if you guys are interested in this, or a different implementation of the same thing, but we need the ability to run some tests in a specific order before others, so we're handling the randomization before feeding them to the SLTestController.

    opened by j-mutter 8
  • Cannot find table cell with custom layout

    Cannot find table cell with custom layout

    I have a UITableViewCell that uses a custom layout with a UILabel inside of it. When I do logElementTree on the main window, I see the cell in the list and it says its name is "foo". However, [SLElement elementWithAccessibilityLabel:@"foo"] does not find the cell. Manually setting the accessibilityLabel of the cell itself did not help. On the other hand, if I manually set the cell's accesibilityIdentifier to "foo" and use [SLElement elementWithAccessibilityIdentifier:@"foo"] that works fine.

    I can try to provide sample code and/or a failing test if you need more info.

    opened by phatmann 8
  • Please merge Xcode6 branch into master

    Please merge Xcode6 branch into master

    Please merge the Xcode6 branch into master. I have spent a long time digging through various forks to get to a working Xcode6 implementation, and I've come to the conclusion that 95% of it is already on inkling/shared/Xcode6. (I have couple of changesets to follow).

    opened by ewanmellor 1
  • If app crashes, start it up to upload crash logs

    If app crashes, start it up to upload crash logs

    Added -upload_crash_logs <upload_time> parameter to start up the same simulator or device that ran the tests if the app crashed so that logs can be uploaded.

    opened by johnwen 1
Releases(v1.1.0)
  • v1.1.0(May 1, 2014)

    It's been a looong time since the last official release. We've got a lot to show for it, though: Subliminal and its documentation have been overhauled to make it easier to install and use. From Cocoapods support to pretty-printed CI output, there's a lot to love in this release.

    You can find an installation walkthrough here, and instructions on updating here.

    Updated Requirements
    • Subliminal now requires Xcode 5.1. iOS 5.1 is still supported, though this is the last release to support iOS 5.1. To test in the iOS 5.1 Simulator, users must run OS X 10.8 and manually add the iOS 5.1 Simulator to Xcode as described here.
    • Subliminal no longer requires the user's password to run from the command-line. Users should stop passing the -login_password and --live options to the subliminal-test script and instead pre-authorize their computers to run Instruments.
    Changes
    • Subliminal no longer requires the user's password to run from the command line
    • Use Instrument's new -w flag to run on a specific device or simulator
    • Cocoapods support
    • Pretty-printed test output
    • Randomized test order
    • Support testing on a device without the app having already been installed
    • Support retina devices
    • ...as well as many smaller enhancements and fixes.

    See the full changelog here.

    Thanks to @MaxGabriel, @j-mutter, @jzucker2, @jazzychad, @nzhuk, @raven, @j2bbayle, @titangate, @ewanmellor, and @aegolden who all contributed code to this release. Cheers! :beers:

    Source code(tar.gz)
    Source code(zip)
Owner
Inkling
Inkling
Switchboard - easy and super light weight A/B testing for your mobile iPhone or android app. This mobile A/B testing framework allows you with minimal servers to run large amounts of mobile users.

Switchboard - easy A/B testing for your mobile app What it does Switchboard is a simple way to remote control your mobile application even after you'v

Keepsafe 287 Nov 19, 2022
Testing the UI without UI Testing, a Swift experiment.

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-le

Joe Masilotti 20 Sep 26, 2022
Library for unifying the approach to network mocking in iOS unit- & UI-tests.

TinkoffMockStrapping Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installati

Online financial ecosystem 22 Jan 3, 2023
Snapshot testing tool for iOS and tvOS

SnapshotTest is a simple view testing tool written completely in Swift to aid with development for Apple platforms. It's like unit testing for views.

Pär Strindevall 44 Sep 29, 2022
Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.

StoreHelper Demo Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5, iOS 15. See also In-App Purchases with Xcode 12 and

Russell Archer 192 Dec 17, 2022
A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Spry Spry is a Swift Playgrounds Unit Testing library based on Nimble. The best thing about Spry is that the API matches Nimble perfectly. Which means

Quick 327 Jul 24, 2022
Multivariate & A/B Testing for iOS and Mac

This library is no longer being maintained. You can continue to use SkyLab in your projects, but we recommend switching another solution whenever you

Mattt 792 Dec 15, 2022
Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

Elevate 78 Jan 13, 2021
AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

Recruit Marketing Partners Co.,Ltd 113 Nov 11, 2022
Keep It Functional - An iOS Functional Testing Framework

IMPORTANT! Even though KIF is used to test your UI, you need to add it to your Unit Test target, not your UI Test target. The magic of KIF is that it

KIF Framework 6.2k Dec 29, 2022
Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine

Bluepill is a tool to run iOS tests in parallel using multiple simulators. Motivation LinkedIn created Bluepill to run its large iOS test suite in a r

Mobile Native Foundation 3.1k Jan 3, 2023
iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.

SnappyTestCase iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase. Why? Snapshot testing helps to deliver views that

Tooploox 15 Oct 11, 2019
Sample project for testing out focus in SwiftUI and iOS 15

This project was to test out different ways of enabling focus in a SwiftUI app.

null 3 Dec 21, 2021
A flexible mock server for automated and regression testing of iOS, Android and other apps.

Note: This document is intended as a quick introduction to Voodoo. As Voodoo has a large number of features, please refer to Voodoo's Github Wiki for

Derek Clarkson 7 Nov 23, 2022
Network testing for Swift

DVR DVR is a simple Swift framework for making fake NSURLSession requests for iOS, watchOS, and OS X based on VCR. Easy dependency injection is the ma

Venmo 650 Nov 3, 2022
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Quick 9.6k Dec 31, 2022
UI Testing Cheat Sheet and Examples.

UI Testing Cheat Sheet This repository is complementary code for my post, UI Testing Cheat Sheet and Examples. The post goes into more detail with exa

Joe Masilotti 2.1k Dec 25, 2022
Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS

Mockingbird Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS, allowing a team to test and develop

FARFETCH 183 Dec 24, 2022
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur

Buildasaur Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running

Buildasaurs 774 Dec 11, 2022