A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Overview

Travis Platforms Xcode Playgrounds iPad Playgrounds License

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 once you've created your code and tests in a Playground, you can copy them directly into your Xcode project without needing to (re)write them again :)

Nimble: The code in this library has been copied directly from the Nimble project. However it is currently a stripped down version.

Download

There are a couple of ways you can download Spry.

Template

You can download a Playground including the latest version of Spry. Consider this a boilerplate template. It includes Spry in the Sources folder of the Playground, so you can simply start writing tests alongside your code in the Playground.

iPad Playgrounds
Xcode Playgrounds

Manual

You can also download or checkout this repo and simply copy the files into your existing Playground manually. Simply copy the entire Spry folder into your Playground's Sources folder. Easy Peasy!

Nimble-esque

Spry is a stripped down (Lite) version of Nimble that includes a subset of Nimble's Matchers.

Note: This is a port of Nimble only, since Quick doesn't really make sense in the context of a Playground.

The following features are NOT supported (since they are a part of Quick):

describe
context
it

The following features are already implemented:

  • expect
  • to
  • beAKindOf
  • beAnInstanceOf
  • beCloseTo
  • beEmpty
  • beginWith
  • beGreaterThan
  • beGreaterThanOrEqualTo
  • beIdenticalTo
  • beLessThan
  • beLessThanOrEqualTo
  • beLogical
  • beNil
  • beVoid
  • containElementSatisfying
  • contain
  • endWith
  • equal
  • haveCount
  • match
  • satisfyAnyOf

The following features are not yet implemented:

  • toEventually
  • async
  • matchError
  • throwError
  • failWithMessage

Usage

Using Spry is as simple as writing an expect case:

func add<T: ExpressibleByIntegerLiteral>(_ x: T, _ y: T) -> T {
    return x + y
}

// Spry test case
expect(add(4, 5)).to(equal(9))

If you're already familiar with Nimble, then you already know how to use Spry.

For full details on how to write your tests with Spry, I suggest reading over the Nimble docs. Keeping in mind that not all features are currently included.

Comments
  • Possible bug : matchers not being recognized, but...

    Possible bug : matchers not being recognized, but...

    • [X] I have read CONTRIBUTING and have done my best to follow them. I'm pretty sure this is a xCode 9b2 beta bug, but nonetheless..

    What did you do?

    Unzipped, and ran the Playground included with the distribution under xCode 9

    What did you expect to happen?

    Expected it to run as it does in xCode 8.3

    What actually happened instead?

    matchers are unrecognized

    Please replace this with what happened instead.

    Environment

    List the software versions you're using:

    • Spry: ?.?.? Master Branch

    • Xcode Version: ?.? (????) (Open Xcode; In menubar: Xcode > About Xcode) 9.b2

    • Swift Version: ?.? (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.) None: xCode Default

    bug 
    opened by wm-j-ray 3
  • Nimble Integration

    Nimble Integration

    Assuming #1 is successful:

    • Create associated PR for Nimble (if required)
    • Add Nimble as a submodule to the project
    • Add a script to automatically generate the Playgrounds from Nimble source
    opened by shaps80 0
  • Updates for Xcode 9 and Swift 4

    Updates for Xcode 9 and Swift 4

    Updating mostly syntax changes for Swift 4, as well as taking the recommending project settings from Xcode 9.

    This also updates the playgrounds to use the updated sources. It allowed me to use Spry in Xcode 9, but I do not have an iPad to test out the iPad playground.

    opened by thedavidharris 0
  • Fix hardcoded expectation result

    Fix hardcoded expectation result

    • What behavior was changed? beGreaterThan, beGreaterThanOrEqualTo, and beLessThanOrEqual have hardcoded expectation result, which results in an error if the type of ExpectationResult changes.

    • What code was refactored / updated to support this change? The files corresponding to each matcher.

    • What issues are related to this PR? Or why was this change introduced? Tried replacing type of ExpectationResult to String since colors don't show preview in my Xcode (Xcode 8.3).

    • [ ] Does this have tests? Can't create a test since the type of ExpectationResult is set at compile time.

    • [ ] Does this have documentation?

    • [ ] Does this break the public API (Requires major version bump)?

    • [ ] Is this a new feature (Requires minor version bump)?

    opened by chrisamanse 0
  • Potential for tick / cross emoji?

    Potential for tick / cross emoji?

    I recall seeing this on Twitter awhile back and thinking it was cool.

    It can look cleaner to use emoji for the test results in the timeline: ✅ ❌

    Just a thought!

    question 
    opened by ceeK 9
Owner
Quick
The Swift (and Objective-C) testing framework.
Quick
Runtime introspection and unit testing of SwiftUI views

ViewInspector ??️‍♂️ for SwiftUI ViewInspector is a library for unit testing SwiftUI views. It allows for traversing a view hierarchy at runtime provi

Alexey Naumov 1.5k Jan 8, 2023
SwiftCheck is a testing library that automatically generates random data for testing of program properties

SwiftCheck QuickCheck for Swift. For those already familiar with the Haskell library, check out the source. For everybody else, see the Tutorial Playg

TypeLift 1.4k Dec 21, 2022
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
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
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

Kyle Fuller 392 Jan 1, 2023
PlaygroundTester enables you to easily run tests for your iPad Playgrounds 4 project.

PlaygroundTester PlaygroundTester is a package that enables you to add tests to your iPad Swift Playgrounds project. Installation Just add PlaygroundT

Paweł Łopusiński 36 Dec 13, 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
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

Apple 1k Jan 4, 2023
Fastbot is a model-based testing tool for modeling GUI transitions to discover app stability problems

Fastbot is a model-based testing tool for modeling GUI transitions to discover app stability problems. It combines machine learning and reinforcement learning techniques to assist discovery in a more intelligent way.

Bytedance Inc. 446 Dec 29, 2022
TestSchedulerDemo - Demonstration code for iOS Unit Tests and Asynchronous

TestSchedulerDemo This repository contains demonstration code for my Medium arti

Carsten Wenderdel 0 Mar 19, 2022
Marvel - Marvel Characters App using MVVM, and including unit tests

Marvel About The purpose of this project is to develop a app using MVVM, and inc

null 1 Mar 20, 2022
Detailed explanations and implementations of various maths concepts for writing high performance code/algorithms backed with Unit tests.

Detailed explanations and implementations of various maths concepts which can help software Engineers write high performance code/algorithms backed with Unit tests.

Mussa Charles 2 Sep 25, 2022
Snapshot view unit tests for iOS

iOSSnapshotTestCase (previously FBSnapshotTestCase) What it does A "snapshot test case" takes a configured UIView or CALayer and uses the necessary UI

Uber Open Source 1.7k Jan 4, 2023
Mockit is a Tasty mocking framework for unit tests in Swift 5.0

Mockit Introduction Mockit is a Tasty mocking framework for unit tests in Swift 5.0. It's at an early stage of development, but its current features a

Syed Sabir Salman-Al-Musawi 118 Oct 17, 2022
Trying to implement Unit Tests for @Binding properties in a ViewModel

BindingTester Trying to implement Unit Tests for @Binding properties in a ViewModel ViewModel to be tested class SheetViewModel: ObservableObject {

Raphael Guye 0 Oct 22, 2021
Catching fatal errors in unit tests

Precondition Catching When running tests which hit fatal errors, often preconditions the built-in support with XCTest. One package which supports cach

Brennan Stehling 0 Nov 28, 2021
Write unit tests which test the layout of a view in multiple configurations

Overview This library enables you to write unit tests which test the layout of a view in multiple configurations. It tests the view with different dat

LinkedIn 565 Nov 16, 2022
XCTestExtensions is a Swift extension that provides convenient assertions for writing Unit Test.

XCTestExtensions Features XCTAssertEventually (that convenient assertions for writing Unit Test). Use "XCTAssertEventually", you can write asynchronou

shindyu 22 Dec 1, 2022