Latest 0.0.3
Homepage https://github.com/ScottPetit/SPYTestLog
License MIT
Platforms ios , requires ARC
Frameworks XCTest
Authors

XCTest meet XcodeColors

SPYTestLog is a simple test utility to add some color to your Xcode console. Instead of the drab and plain logs of plain ole XCTestLog

XCTestLog

You get the colorful output of SPYTestLog

SPYTestLog

Integration

SPYTestLog has a dependency on XcodeColors to display colorful output in your Xcode console. You should first follow the instructions to get that installed (probably easiest through Alcatraz). Please note that if you’re working with a team and they don’t have XcodeColors installed then they will continue to see the same default XCTestLogs.

The best and fastest way of integrating SPYTestLog is with CocoaPods. SPYTestLog should only be added to your test target so adding it would look something like

target :YOUR_TEST_TARGET, :exclusive => true do
  pod 'SPYTestLog'
end

After adding that to your pod file and pod updating or installing you can tell your project to use SPYTestLog by adding the following to your application:didFinishLaunchingWithOptions:

 #ifdef DEBUG
     [[NSUserDefaults standardUserDefaults] setObject:@"SPYTestLog" forKey:@"XCTestObserverClass"];
     [[NSUserDefaults standardUserDefaults] synchronize];
 #endif

This is the Apple’s preferred way of adding TestLogs to XCTest.

Caveats

One caveat is that SPYTestLog will add the format for XcodeColors to command line builds as well. This means that if locally you run ‘xcodebuild’ there will be formatting in some of your test logs. This also means that if locally you use ‘xcodebuild’ with something like XCPretty you won’t get any output for your test logs. If you have any suggestions for a way to fix this I’m all ears.

This however shouldn’t effect Continuous Integration servers (assuming they don’t have XcodeColors installed) as SPYTestLog will just fall back to the normal log if XcodeColors is not installed.

This also doesn’t seem to effect command line builds using XCTool.

Subclassing

Subclasses can override the colors of the output by overriding

- (NSString *)testCasePassedColor;
- (NSString *)testCaseFailedColor;

and providing a properly formatted XcodeColor. For reference the implementation of looks like this.

- (NSString *)testCasePassedColor
{
    return @"fg127,175,27;";
}

Latest podspec

{
    "name": "SPYTestLog",
    "version": "0.0.3",
    "authors": {
        "Scott Petit": "[email protected]"
    },
    "homepage": "https://github.com/ScottPetit/SPYTestLog",
    "summary": "XcodeColors meets XCTest",
    "source": {
        "git": "https://github.com/ScottPetit/SPYTestLog.git",
        "tag": "v0.0.3"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": null
    },
    "requires_arc": true,
    "frameworks": "XCTest",
    "source_files": "SPYTestLog/"
}

Pin It on Pinterest

Share This