@@ -31,24 +31,31 @@ Add `.package(name: "Difference", url: "https://github.com/krzysztofzablocki/Dif
3131
3232## Using lldb
3333
34- Just write the following to see the difference between 2 instances:
34+ Write the following to see the difference between 2 instances:
3535
3636` po dumpDiff(expected, received) `
3737
3838
3939## Integrate with XCTest
40- Just add this to your test target:
40+ Add this to your test target:
4141
4242``` swift
43- public func XCTAssertEqual <T : Equatable >(_ expected : T, _ received : T, file : StaticString = #file , line : UInt = #line ) {
44- XCTAssertTrue (expected == received, " Found difference for \n " + diff (expected, received).joined (separator : " , " ), file : file, line : line)
43+ public func XCTAssertEqual <T : Equatable >(_ expected : @autoclosure () throws -> T, _ received : @autoclosure () throws -> T, file : StaticString = #filePath , line : UInt = #line ) {
44+ do {
45+ let expected = try expected ()
46+ let received = try received ()
47+ XCTAssertTrue (expected == received, " Found difference for \n " + diff (expected, received).joined (separator : " , " ), file : file, line : line)
48+ }
49+ catch {
50+ XCTFail (" Caught error while testing: \( error ) " , file : file, line : line)
51+ }
4552}
4653```
4754
48- Replace ` #file ` with ` #filePath ` if you're using Xcode 12+ .
55+ Replace ` #filePath ` with ` #file ` if you're using Xcode 11 or earlier .
4956
5057## Integrate with Quick
51- Just add this to your test target:
58+ Add this to your test target:
5259
5360``` swift
5461public func equalDiff <T : Equatable >(_ expectedValue : T? ) -> Predicate<T> {
0 commit comments