Skip to content

Instantly share code, notes, and snippets.

@jmnavarro
Created January 31, 2013 11:59
Show Gist options
  • Save jmnavarro/4682392 to your computer and use it in GitHub Desktop.
Save jmnavarro/4682392 to your computer and use it in GitHub Desktop.
Determine if host app is running in test environment or in real one. Usefull to use in applicationDidFinishLaunching to change the startup path.
//
// NSProcessInfo+DetectTestEnvironment.h
// Memoir
//
// Created by JM - http://jmnavarro.github.com
//
#import <Foundation/Foundation.h>
@interface NSProcessInfo (DetectTestEnvironment)
- (BOOL)isRunningTests;
@end
//
// NSProcessInfo+DetectTestEnvironment.m
//
// Created by JM - http://jmnavarro.github.com
//
#import "NSProcessInfo+DetectTestEnvironment.h"
@implementation NSProcessInfo (DetectTestEnvironment)
- (BOOL)isRunningTests {
for (NSString *arg in [[NSProcessInfo processInfo] arguments]) {
if ([[arg lowercaseString] isEqualToString:@"-sentest"] || [arg hasSuffix:@".octests"]) {
return YES;
}
}
return NO;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment