GithubHelp home page GithubHelp logo

cyber-rick-sanchez / assert Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johnsundell/assert

0.0 1.0 0.0 52 KB

A collection of convenient assertions for Swift testing

License: MIT License

Swift 100.00%

assert's Introduction

Assert

Swift Package Manager Twitter: @johnsundell

This repo contains a collection of assertion functions that you can use in your tests, as a complement to the assertions provided by XCTest, or other testing frameworks. This collection will likely grow over time, and you are more than welcome to contribute your own custom assertion functions as a pull request! ๐Ÿš€

What's in the box?

Here is what you can currently assert using the functions that Assert provides:

That an expression threw a given error:

assert(try myFunction(), throwsError: MyError.anError)

That a closure threw a given error:

assertErrorThrown(MyError.anError) {
    try myFunction()
}

That a closure didn't throw an error:

assertNoErrorThrown {
    try myFunction()
}

That two objects are the same instance:

assertSameInstance(objectA, objectB)

Usage

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/johnsundell/assert", from: "1.0.0")

Then, you can import Assert in your tests, like this:

import Assert

Manually

You can also simply clone the repo, and drag the file Sources/Assert.swift into your Xcode project and add it to your test target.

Contributing

To work on Assert in Xcode, first generate an Xcode project through the Swift Package Manager:

$ swift package generate-xcodeproj

Then, make your changes to Assert.swift, and submit a pull request with your changes.

Questions or feedback?

Feel free to open an issue, or find me @johnsundell on Twitter.

assert's People

Contributors

johnsundell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.