Get Updates By E-mail 

Article Written By:
Johann Dowa

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>
...

+(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];

// Not enough, let's make 10 people!
NSArray *bunchOfPeople = [Person foundryBuildNumber:10];

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments