Project

objc

0.0
No commit activity in last 3 years
No release in over 3 years
This gem is a test suite runner for Objective-C files to allow for the easy execution of a test suite without the hassle of managing an Xcode Project File. This allows you to work on your source files outside of a Xcode project but still have them tested. This is useful when when you want to practice Objective-C without the hassle of Xcode.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 11.2

Runtime

~> 0.1.15
~> 0.2.6
 Project Readme

Objc

This gem is a test suite runner for Objective-C files to allow for the easy execution of a test suite without the hassle of managing an Xcode Project File

Installation

Install the gem

$ gem install objc

Install xctool

$ brew install xctool

Usage

$ objc Bob

The objc binary will find and run the tests for the following files: Bob.h, Bob.m and BobTest.m.

The test suite used is XCTest. This is an example of the header, source and test file.

Bob.h

#import <Foundation/Foundation.h>

@interface Bob : NSObject

- (NSString *)hey:(NSString *)statement;

@end

Bob.m

#import "Bob.h"

@implementation Bob

-(NSString *)hey:(NSString *)statement {

  if ([statement isEqualToString:@""]) {
    return @"Fine, be that way.";
  } else if ([statement hasSuffix:@"?"]) {
    return @"Sure.";
  } else if ([statement isEqualToString:[statement uppercaseString]]) {
    return @"Woah, chill out!";
  } else {
    return @"Whatever.";
  }

}

@end

BobTest.m

#import <XCTest/XCTest.h>
#import "Bob.h"

@interface test_suite : XCTestCase

@end

@implementation test_suite

- (Bob *)bob {
  return [[Bob alloc] init];
}

- (void)testStatingSomething {
  NSString *input = @"Tom-ay-to, tom-aaaah-to.";
  NSString *expected = @"Whatever.";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testShouting {
  NSString *input = @"WATCH OUT!";
  NSString *expected = @"Woah, chill out!";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testAskingAQuestion {
  NSString *input = @"Does this cryogenic chamber make me look fat?";
  NSString *expected = @"Sure.";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testTalkingForcefully {
  NSString *input = @"Let's go make out behind the gym!";
  NSString *expected = @"Whatever.";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testShoutingNumbers {
  NSString *input = @"1, 2, 3 GO!";
  NSString *expected = @"Woah, chill out!";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testShoutingWithSpecialCharacters {
  NSString *input = @"ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!";
  NSString *expected = @"Woah, chill out!";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

- (void)testSilence {
  NSString *input = @"";
  NSString *expected = @"Fine, be that way.";
  NSString *result = [[self bob] hey:input];
  XCTAssertEqual(expected,result);
}

@end

Details

When you run objc Bob, more specifically the following occurs:

  • Finds the files matching the specified prefix (e.g. Bob.h, Bob.m and BobTest.m)
  • An Xcode Project, managed by the gem, is copied to to a tmp location on the system.
  • Using the xcoder the project file is manipulated and the found files are added.
  • Using xctool the tests from the project file are executed.

Limitations

  • Currently the template project is a Cocoa App that will launch a window for a brief moment during the tets. I couldn't get a project with just tests to run with xctool or xcodebuild.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request