I’ve mentioned a number of libraries and tools for easier testing of Objective-C and Swift programs, most recently and Rspec inspired BDD testing framework for Swift known as Quick.
Here’s an interesting library known as Fox from Jeff Hui for automatic testing of Objective-C and swift programs based on Haskell’s QuickCheck called Fox.
Fox automatically generates test data and this example from the readme shows some simple generation of testing values:
// reads: for all integers x, y: x + y > x
FOXRunnerResult *result = [runner checkWithNumberOfTests:100
forAll:FOXTuple(FOXInteger(), FOXInteger())
then:^FOXPropertyResult(NSArray *tuple) {
NSInteger x = [tuple[0] integerValue];
NSInteger y = [tuple[1] integerValue];
// FOXRequire converts bool into the FOXPropertyResult enum for passing or failing
return FOXRequire(x + y > x);
}];
// verify
result.succeeded // => NO; failed
result.failingValue // => @[-9, @0]; random values generated
Extensive documentation is included a tutorial to get you started quickly.
You can find Fox on Github here, and more details about Fox can be found over on the documentation page.
An interesting tool for automatic property based testing.
Original article: A Library For Automatic Testing Of Objective-C And Swift Programs Based On Haskell’s QuickCheck
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.