aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UnitTesting/GTMCodeCoverageApp.m6
-rw-r--r--UnitTesting/GTMCodeCoverageTestsST.m11
-rw-r--r--UnitTesting/GTMCodeCoverageTestsXC.m11
3 files changed, 28 insertions, 0 deletions
diff --git a/UnitTesting/GTMCodeCoverageApp.m b/UnitTesting/GTMCodeCoverageApp.m
index 3bc7fae..415d0c0 100644
--- a/UnitTesting/GTMCodeCoverageApp.m
+++ b/UnitTesting/GTMCodeCoverageApp.m
@@ -25,6 +25,10 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
extern void __gcov_flush();
@implementation UIApplication(GTMCodeCoverage)
@@ -54,3 +58,5 @@ extern void __gcov_flush();
#endif // GTM_USING_XCTEST
@end
+
+#endif // GTM_IS_COVERAGE_BUILD
diff --git a/UnitTesting/GTMCodeCoverageTestsST.m b/UnitTesting/GTMCodeCoverageTestsST.m
index a73fdad..0159a53 100644
--- a/UnitTesting/GTMCodeCoverageTestsST.m
+++ b/UnitTesting/GTMCodeCoverageTestsST.m
@@ -28,6 +28,12 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
+extern void __gcov_flush();
+
static int gSuiteCount = 0;
@interface GTMCodeCoverageTests : NSObject
@@ -63,7 +69,12 @@ static int gSuiteCount = 0;
if ([application respondsToSelector:@selector(gtm_gcov_flush)]) {
[application performSelector:@selector(gtm_gcov_flush)];
}
+
+ // Call flush for this executable unit.
+ __gcov_flush();
}
}
@end
+
+#endif // GTM_IS_COVERAGE_BUILD
diff --git a/UnitTesting/GTMCodeCoverageTestsXC.m b/UnitTesting/GTMCodeCoverageTestsXC.m
index 39e4850..b960c26 100644
--- a/UnitTesting/GTMCodeCoverageTestsXC.m
+++ b/UnitTesting/GTMCodeCoverageTestsXC.m
@@ -28,6 +28,12 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
+extern void __gcov_flush();
+
@interface GTMCodeCoverageTests : XCTestObserver
@end
@@ -42,6 +48,9 @@
[application performSelector:@selector(gtm_gcov_flush)];
}
+ // Call flush for this executable unit.
+ __gcov_flush();
+
// Reset defaults back to what they should be.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:XCTestObserverClassKey];
@@ -70,3 +79,5 @@
}
@end
+
+#endif // GTM_IS_COVERAGE_BUILD