github typelift/SwiftCheck v0.4.0
Reproductive Rights

latest releases: 0.12.0, 0.11.0, 0.10.1...
8 years ago

SwiftCheck now has a new in-library pseudo-RNG that enables tests to be replayed argument-for-argument with just two seed values.

For example, given this property:

property("Obviously wrong") <- forAll { (x : Int, y : Int, c : Int) in (x > y) ==> x + c < y + c }

SwiftCheck takes care of printing all the nitty-gritty details.

screen shot 2015-11-18 at 7 20 33 pm

So all you have to do is feed those values back into the testing loop:

let (seedl, seedr) = (618383975, 8314)
let replayArgs = CheckerArguments(replay: .Some(StdGen(seedl, seedr), 1))
property("Obviously wrong", arguments: replayArgs) <- forAll { (x : Int, y : Int, c : Int) in (x > y) ==> x + c < y + c }.verbose

In addition, this release comes with a number of bug fixes and improvements:

  • SwiftCheck now uses the @exported attribute with XCTest so you can just import SwiftCheck without needing to import XCTest.
  • Test cases that throw exceptions now also print counterexamples. Whoops!
  • The CheckerArguments structure is now easier to create and use (h/t @kballard).
  • The StdGen structure is now public.

Don't miss a new SwiftCheck release

NewReleases is sending notifications on new releases.