Skip to content

1.1.0

Compare
Choose a tag to compare
@stephencelis stephencelis released this 19 Sep 04:54
· 25 commits to main since this release
3efbfba

What's Changed

  • Added: XCTAssertDifference for testing changes to values (#51).

    This function evaluates a given expression before and after a given operation and then compares the results. The comparison is done by invoking the changes closure with a mutable version of the initial value, and then asserting that the modifications made match the final value using XCTAssertNoDifference.

    For example, given a very simple counter structure, we can write a test against its incrementing functionality:

    struct Counter {
      var count = 0
      var isOdd = false
      mutating func increment() {
        self.count += 1
        self.isOdd.toggle()
      }
    }
    
    var counter = Counter()
    XCTAssertDifference(counter) {
      counter.increment()
    } changes: {
      $0.count = 1
      $0.isOdd = true
    }

    If changes does not exhaustively describe all changed fields, the assertion will fail.

    By omitting the operation you can write a "non-exhaustive" assertion against a value by describing just the fields you want to assert against in the changes closure:

    counter.increment()
    XCTAssertDifference(counter) {
      $0.count = 1
      // Don't need to further describe how `isOdd` has changed
    }
  • Infrastructure: README updates (thanks @JacksonUtsch, #96).

  • Infrastructure: Enable Windows CI (thanks @brianmichel, #99).

New Contributors

Full Changelog: 1.0.0...1.1.0