Two Objective-C Libraries For Easier Testing Inspired By Ruby’s Factory Girl And MBFaker

I’ve mentioned a number of libraries and tools to aid in testing, such as the UIAutomation framework that uses Objective-C.

Here are two libraries created to ease testing submitted by John Tumminaro – Foundry for creating test/mock objects inspired by Ruby’s Factory_girl, and Gizou inspired by Ruby’s MBFaker for generating sample data.

As John states in his submission:

“Foundry (and its sister project Gizou) are two libraries I built due to the lack of really great factory/mock data libraries for Objective-C developers. I really liked my experience with libraries like factory_girl in the Ruby universe and I took a lot of inspiration from it to create these two.”

Foundry allows you to easily build a spec and create objects like this example created from the readme:

@interface Person : NSObject <tgfoundryobject>

<ul>
<li>(NSDictionary *)foundryBuildSpecs
{
return @{
    @"name": [NSNumber numberWithInteger:FoundryPropertyTypeName],
    @"email": [NSNumber numberWithInteger:FoundryPropertyTypeEmail],
    @"password": [NSNumber numberWithInteger:FoundryPropertyTypeLoremIpsumShort]
};
}

and create the specs you want like this:

    // Let’s build a single person first.
    Person *fullPerson = [Person foundryBuild];

<pre><code>// Not enough, let’s make 10 people!
NSArray *bunchOfPeople = [Person foundryBuildNumber:10];
</code></pre>

Gizou provides extensive support for generating test data and not only allows you to create realistic data for names, emails and addresses, but also has support for test images, and nearby locations with a number of nice convenience categories.

Both projects are well documented with some examples included.

You can find Foundry on Github here.

You can find Gizou on Github here.

Two very nice libraries to simplify testing of Objective-C projects.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Two Objective-C Libraries For Easier Testing Inspired By Ruby’s Factory Girl And MBFaker

©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *