Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tokorom committed Jan 1, 2014
1 parent eba703c commit 58dcea6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
8 changes: 8 additions & 0 deletions GenerateTestCoverageFor_iOS7.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
06F7A73C1873F91700734089 /* Sample.m in Sources */ = {isa = PBXBuildFile; fileRef = 06F7A73A1873F91200734089 /* Sample.m */; };
06F7A7421873FB0100734089 /* TKRGcovFluserTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 06F7A73F1873FB0100734089 /* TKRGcovFluserTestObserver.m */; };
06F7A7431873FB0100734089 /* TKRGcovFlusher.m in Sources */ = {isa = PBXBuildFile; fileRef = 06F7A7411873FB0100734089 /* TKRGcovFlusher.m */; };
06F7A74518744DB300734089 /* GcovFlusherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 06F7A74418744DB300734089 /* GcovFlusherTest.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -65,6 +66,7 @@
06F7A73F1873FB0100734089 /* TKRGcovFluserTestObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKRGcovFluserTestObserver.m; sourceTree = "<group>"; };
06F7A7401873FB0100734089 /* TKRGcovFlusher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKRGcovFlusher.h; sourceTree = "<group>"; };
06F7A7411873FB0100734089 /* TKRGcovFlusher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKRGcovFlusher.m; sourceTree = "<group>"; };
06F7A74418744DB300734089 /* GcovFlusherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GcovFlusherTest.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -153,6 +155,7 @@
06F7A7291873DA6300734089 /* Tests */ = {
isa = PBXGroup;
children = (
06F7A74418744DB300734089 /* GcovFlusherTest.m */,
06F7A72F1873DA6300734089 /* SampleTests.m */,
06F7A72A1873DA6300734089 /* Supporting Files */,
);
Expand Down Expand Up @@ -288,6 +291,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
06F7A74518744DB300734089 /* GcovFlusherTest.m in Sources */,
06F7A7431873FB0100734089 /* TKRGcovFlusher.m in Sources */,
06F7A7421873FB0100734089 /* TKRGcovFluserTestObserver.m in Sources */,
06F7A7301873DA6300734089 /* SampleTests.m in Sources */,
Expand Down Expand Up @@ -458,6 +462,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/Tests-Info.plist";
OTHER_CFLAGS = "-DUNUSE_GCOV_FLUSH";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
Expand All @@ -477,6 +482,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "App/App-Prefix.pch";
INFOPLIST_FILE = "Tests/Tests-Info.plist";
OTHER_CFLAGS = "-DUNUSE_GCOV_FLUSH";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
Expand All @@ -502,6 +508,7 @@
06F7A7351873DA6300734089 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
06F7A7361873DA6300734089 /* Build configuration list for PBXNativeTarget "Tests" */ = {
isa = XCConfigurationList;
Expand All @@ -510,6 +517,7 @@
06F7A7381873DA6300734089 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ test-with-coverage:
-destination $(DESTINATION) \
OBJROOT=$(OBJDIR) \
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES \
GCC_GENERATE_TEST_COVERAGE_FILES=YES
GCC_GENERATE_TEST_COVERAGE_FILES=YES \
OTHER_CFLAGS="-DUSE_GCOV_FLUSH"

coverstory:
make test-with-coverage
/Applications/CoverStory.app/Contents/MacOS/CoverStory $(OBJDIR)
/Applications/CoverStory.app/Contents/MacOS/CoverStory $(OBJDIR) &

coveralls:
coveralls \
Expand Down
39 changes: 39 additions & 0 deletions Tests/GcovFlusherTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// GcovFlusherTest.m
//
// Created by ToKoRo on 2014-01-01.
//

#import <XCTest/XCTest.h>
#import "TKRGcovFlusher.h"

@interface TKRGcovFlusher ()
+ (void)updateTestObserverClassName:(NSString*)className;
@end

@interface GcovFlusherTest : XCTestCase
@end

@implementation GcovFlusherTest

- (void)testUpdateTestObserver
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"XCTestLog" forKey:XCTestObserverClassKey];
[defaults synchronize];

[TKRGcovFlusher updateTestObserverClassName:@"TKRGcovFluserTestObserver"];
NSString *currentObserverString = [defaults stringForKey:XCTestObserverClassKey];
NSArray *currentObservers = [currentObserverString componentsSeparatedByString:@","];

XCTAssertTrue([currentObservers containsObject:@"TKRGcovFluserTestObserver"]);

NSUInteger beforeCount = currentObservers.count;
[TKRGcovFlusher updateTestObserverClassName:@"TKRGcovFluserTestObserver"];
currentObserverString = [defaults stringForKey:XCTestObserverClassKey];
currentObservers = [currentObserverString componentsSeparatedByString:@","];

XCTAssertEqual(currentObservers.count, beforeCount);
}

@end

0 comments on commit 58dcea6

Please sign in to comment.