Latest 0.2
Homepage https://github.com/krzysztofzablocki/Difference
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0
Frameworks Foundation
Authors

CircleCI
Version
License
Platform

Better way to identify whats different between 2 instances.

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

Difference

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?

Difference

Installation

CocoaPods

Add pod 'Difference' to your Podfile.

Carthage

Add github "krzysztofzablocki/Difference" to your Cartfile.

Using lldb

Just write following to see difference between 2 instances:

po dumpDiff(expected, received)

Integrate with XCTest

Just add this to your test target:

public func AssertEqual<T: Equatable>(_ expected: T, _ received: T, file: StaticString = #file, line: UInt = #line) {
    XCTAssertTrue(expected == received, "Found difference for " + diff(expected, received).joined(separator: ", "), file: file, line: line)
}

Integrate with Quick

Just add this to your test target:

public func equalDiff<T: Equatable>(_ otherObject: T?) -> Predicate<T> {
    return Predicate.define { actualExpression in
        guard let otherObject = otherObject else {
            return PredicateResult(status: .fail, message: ExpectationMessage.fail("").appendedBeNilHint())
        }

        let object = try actualExpression.evaluate()

        return PredicateResult(bool: object != otherObject, message: ExpectationMessage.fail("Found difference for " + diff(object, otherObject).joined(separator: ", ")))
    }
}

Latest podspec

{
    "name": "Difference",
    "version": "0.2",
    "summary": "Better way to identify whats different between 2 instances.",
    "description": "Better way to identify whats different between 2 instances. Based on Mirror API.",
    "homepage": "https://github.com/krzysztofzablocki/Difference",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Krzysztof Zablocki": "[email protected]"
    },
    "social_media_url": "",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/krzysztofzablocki/Difference.git",
        "tag": "0.2"
    },
    "source_files": "Sources/**/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This