All Projects → krzysztofzablocki → Difference

krzysztofzablocki / Difference

Licence: mit
Simple way to identify what is different between 2 instances of any type. Must have for TDD.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Difference

Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-37.04%)
Mutual labels:  tvos, watchos
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (-13.5%)
Mutual labels:  tvos, watchos
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (-34.41%)
Mutual labels:  tvos, watchos
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (-7.53%)
Mutual labels:  tvos, watchos
Dynamicjson
Access JSON properties dynamically like JavaScript using Swift 4.2's new @dynamicMemberLookup feature
Stars: ✭ 678 (-19%)
Mutual labels:  tvos, watchos
Swiftyutils
All the reusable code that we need in each project
Stars: ✭ 490 (-41.46%)
Mutual labels:  tvos, watchos
Swiftyrsa
RSA public/private key encryption in Swift
Stars: ✭ 894 (+6.81%)
Mutual labels:  tvos, watchos
Stringz
A lightweight and powerful editor for localizing iOS, macOS, tvOS, and watchOS applications.
Stars: ✭ 440 (-47.43%)
Mutual labels:  tvos, watchos
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+3343.97%)
Mutual labels:  tvos, watchos
Ratelimit
Simple utility for only executing code every so often.
Stars: ✭ 918 (+9.68%)
Mutual labels:  tvos, watchos
Flint
The Flint framework for building apps on Apple platforms using Feature Driven Development
Stars: ✭ 636 (-24.01%)
Mutual labels:  tvos, watchos
Flexibleimage
A simple way to play with the image!
Stars: ✭ 798 (-4.66%)
Mutual labels:  tvos, watchos
Corexlsx
Excel spreadsheet (XLSX) format parser written in pure Swift
Stars: ✭ 481 (-42.53%)
Mutual labels:  tvos, watchos
Samkeychain
Simple Objective-C wrapper for the keychain that works on Mac and iOS
Stars: ✭ 5,389 (+543.85%)
Mutual labels:  tvos, watchos
Gridstack
A flexible grid layout view for SwiftUI
Stars: ✭ 474 (-43.37%)
Mutual labels:  tvos, watchos
Purchases Ios
In-app purchases and subscriptions made easy. iOS, MacOS, iPadOS, tvOS, and WatchOS support.
Stars: ✭ 614 (-26.64%)
Mutual labels:  tvos, watchos
Userdefaultsstore
Why not use UserDefaults to store Codable objects 😉
Stars: ✭ 416 (-50.3%)
Mutual labels:  tvos, watchos
Swiftuipager
Native Pager in SwiftUI
Stars: ✭ 430 (-48.63%)
Mutual labels:  tvos, watchos
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (-30.11%)
Mutual labels:  tvos, watchos
Apprepositorytemplate
The easiest way to start a new application project without any manual configuration
Stars: ✭ 24 (-97.13%)
Mutual labels:  tvos, watchos

Version License Platform

Difference

Better way to identify what's different between 2 instances.

Have you ever written tests? Usually they use equality asserts, e.g. XCTAssertEqual, what happens if the objects aren't equal? Xcode throws a wall of text at you:

This forces you to manually scan the text and try to figure out exactly whats wrong, what if instead you could just learn which property is different?

Installation

CocoaPods

Add pod 'Difference' to your Podfile.

Carthage

Add github "krzysztofzablocki/Difference" to your Cartfile.

SwiftPM

Add .package(name: "Difference", url: "https://github.com/krzysztofzablocki/Difference.git", .branch("master")), dependency in your Package manifest.

Using lldb

Write the following to see the difference between 2 instances:

po dumpDiff(expected, received)

Integrate with XCTest

Add this to your test target:

public func XCTAssertEqual<T: Equatable>(_ expected: @autoclosure () throws -> T, _ received: @autoclosure () throws -> T, file: StaticString = #filePath, line: UInt = #line) {
    do {
        let expected = try expected()
        let received = try received()
        XCTAssertTrue(expected == received, "Found difference for \n" + diff(expected, received).joined(separator: ", "), file: file, line: line)
    }
    catch {
        XCTFail("Caught error while testing: \(error)", file: file, line: line)
    }
}

Replace #filePath with #file if you're using Xcode 11 or earlier.

Integrate with Quick

Add this to your test target:

public func equalDiff<T: Equatable>(_ expectedValue: T?) -> Predicate<T> {
    return Predicate.define { actualExpression in
        let receivedValue = try actualExpression.evaluate()

        if receivedValue == nil {
            var message = ExpectationMessage.fail("")
            if let expectedValue = expectedValue {
                message = ExpectationMessage.expectedCustomValueTo("equal <\(expectedValue)>", "nil")
            }
            return PredicateResult(status: .fail, message: message)
        }
        if expectedValue == nil {
            return PredicateResult(status: .fail, message: ExpectationMessage.fail("").appendedBeNilHint())
        }

        return PredicateResult(bool: receivedValue == expectedValue, message: ExpectationMessage.fail("Found difference for " + diff(expectedValue, receivedValue).joined(separator: ", ")))
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].