XCTestExtensions is a Swift extension that provides convenient assertions for writing Unit Test.

Overview

XCTestExtensions

Build Status

Features

  • XCTAssertEventually (that convenient assertions for writing Unit Test).

    • Use "XCTAssertEventually", you can write asynchronous assertions very easily and intuitively, like Nimble's toEventually.
  • XCTxContext (It is a wrapper of XCTContext.runActivity.)

    • XCTxContext can internally test setup and tearDown of TestClass. Of course you can not do it.

Installation

Installing with Carthage

Add to Cartfile.private

github "shindyu/XCTestExtensions"

Usage

Import XCTestExtensions to Unit tests files:

import XCTestExtensions

Use XCTestExtensions's extensions in your tests:

For example, Applying it to the asynchronous test of the official document of apple, it can be described as follows:

    func testDownloadWebData_UsingXCTAssertEventually() {
        XCTxContext("you can describe context") {
            let url = URL(string: "https://apple.com")!

            var downloadData: Data?

            let dataTask = URLSession.shared.dataTask(with: url) { (data, _, _) in
                downloadData = data
            }

            dataTask.resume()

            XCTAssertNotNilEventually(downloadData)
        }
    }

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/shindyu/XCTestExtensions

License

XCTestExtensions is available as open source under the terms of the MIT License.

You might also like...
Mockit is a Tasty mocking framework for unit tests in Swift 5.0
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

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 {

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

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

A Mac and iOS Playgrounds Unit Testing library based on Nimble.
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

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

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

TestSchedulerDemo - Demonstration code for iOS Unit Tests and Asynchronous

TestSchedulerDemo This repository contains demonstration code for my Medium arti

Marvel - Marvel Characters App using MVVM, and including unit tests
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

Comments
  • Dev2

    Dev2

    set ENABLE_BITCODE = NO

    for this error

    ld: warning: Auto-Linking supplied '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.
    Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$_XCTWaiter", referenced from:
          objc-class-ref in XCTAssertEventually.o
      "_OBJC_CLASS_$_XCTestExpectation", referenced from:
          objc-class-ref in XCTAssertEventually.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    opened by shindyu 0
Releases(v0.8)
Owner
shindyu
iOS developer at Yahoo! JAPAN, Fluxx.inc. like: Swift / TDD / PairProgramming.
shindyu
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
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.

MetovaTestKit is a collection of useful test helpers designed to ease the burden of writing tests for iOS applications. Requirements Installation Usag

null 23 Aug 29, 2021
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
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
I built this application with unit testing and test-driven development to understand TDD theory and practice

TestDrivenDevelopment Description I built this application with unit testing and test-driven development to understand TDD theory and practice, to wri

null 1 Dec 21, 2021
Test-To-Do-List - Test To Do List with core data

test-To-Do-List This is my first pet project with core data Launch screen Main s

Artem 0 Feb 26, 2022
Kfm-ios-test - Test online for iOS Developer position in Kimia Farma or PT. Buana Varia Komputama

kfm-ios-test Kimia Farma Mobile iOS Test Test online for iOS Developer position

Erwindo Sianipar 3 Feb 23, 2022
A convenient mocking framework for Swift

// Mocking let bird = mock(Bird.self) // Stubbing given(bird.getName()).willReturn("Ryan") // Verification verify(bird.fly()).wasCalled() What is Mo

Bird Rides, Inc 545 Jan 5, 2023
Swift framework containing a set of helpful XCTest extensions for writing UI automation tests

AutoMate • AppBuddy • Templates • ModelGenie AutoMate AutoMate is a Swift framework containing a set of helpful XCTest extensions for writing UI autom

PGS Software 274 Dec 30, 2022
Gauntlet is a collection of testing utility methods that aims to make writing great tests easier.

Gauntlet What is Gauntlet? Gauntlet is a collection of testing utility methods that aims to make writing great tests easier and with more helpful and

null 11 Dec 17, 2022