diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2013-11-12 23:00:15 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2013-11-12 23:00:15 +0000 |
commit | 8d4831d5bf6d0c714d7b03b07d8b393063a40916 (patch) | |
tree | bab1ce6cda87ba622da6e9f0668fc7f86bd5a05e /UnitTesting/GTMCodeCoverageApp.m | |
parent | 1e00b7a50df68a4c7200781fa5598030d06f5ee3 (diff) |
Add GoogleTestRunner to GTM.
This allows you to easily mix and match SenTest with GoogleTest
https://code.google.com/p/googletest/
which is nice when working with C++ code.
Also adds GTMCodeCoverage which allows you to do code coverage with Xcode 5 and iOS7.
DELTA=424 (424 added, 0 deleted, 0 changed)
Diffstat (limited to 'UnitTesting/GTMCodeCoverageApp.m')
-rw-r--r-- | UnitTesting/GTMCodeCoverageApp.m | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/UnitTesting/GTMCodeCoverageApp.m b/UnitTesting/GTMCodeCoverageApp.m new file mode 100644 index 0000000..3bc7fae --- /dev/null +++ b/UnitTesting/GTMCodeCoverageApp.m @@ -0,0 +1,56 @@ +// +// GTMCodeCovereageApp.m +// +// Copyright 2013 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +// This code exists for doing code coverage with Xcode and iOS. +// Please read through https://code.google.com/p/coverstory/wiki/UsingCoverstory +// for details. + +// This file should be conditionally compiled into your application bundle +// or test rig when you want to do code coverage. + +#import "GTMCodeCoverageApp.h" + +extern void __gcov_flush(); + +@implementation UIApplication(GTMCodeCoverage) + +- (void)gtm_gcov_flush { + __gcov_flush(); +} + +#if GTM_USING_XCTEST + ++ (void)load { + // Using defines and strings so that we don't have to link in + // XCTest here. + // Must set defaults here. If we set them in XCTest we are too late + // for the observer registration. + // See the documentation of XCTestObserverClassKey for why we set this key. + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *observers = [defaults stringForKey:GTMXCTestObserverClassKey]; + NSString *className = @"GTMCodeCoverageTests"; + if (observers == nil) { + observers = GTMXCTestLogClass; + } + observers = [NSString stringWithFormat:@"%@,%@", observers, className]; + [defaults setValue:observers forKey:GTMXCTestObserverClassKey]; +} + +#endif // GTM_USING_XCTEST + +@end |