https://github.com/burtlo/objc
Run Objective-C source and test files without the project file getting in the way
https://github.com/burtlo/objc
Last synced: about 2 months ago
JSON representation
Run Objective-C source and test files without the project file getting in the way
- Host: GitHub
- URL: https://github.com/burtlo/objc
- Owner: burtlo
- License: mit
- Created: 2013-10-22T05:59:17.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-16T19:14:23.000Z (about 8 years ago)
- Last Synced: 2025-04-11T02:07:15.624Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 76.2 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this 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](https://github.com/facebook/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@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
#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](https://github.com/rayh/xcoder) the project file is
manipulated and the found files are added.
* Using [xctool](https://github.com/facebook/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