Authored by 周蓉君

更新测试样例。Review by 阿瑟。

... ... @@ -11,7 +11,7 @@
@implementation NSString (YHAnalytics)
- (NSString *) md5
- (NSString *)md5
{
const char *cStr = [self UTF8String];
unsigned char result[16];
... ...
... ... @@ -315,7 +315,7 @@ static dispatch_queue_t persisitingQueue;
// 删除本地持久化文件
- (void)removeLocalFile
{
if ([[NSFileManager defaultManager] fileExistsAtPath: self.eventFilePath]) {
if ([[NSFileManager defaultManager] fileExistsAtPath:self.eventFileName]) {
[[NSFileManager defaultManager] removeItemAtPath:self.eventFileName error:nil];
}
self.allEventsCount = 0;
... ...
... ... @@ -122,17 +122,15 @@ void uncaughtCrashExceptionHandler(NSException *exception)
{
NSLog(@"crash============:\n%@", userInfo);
if (userInfo) {
[[YH_Analytics shareInstance]logError:@"CRASH" parameters:@{ JsonKeyErrorST: userInfo}];
[[YH_Analytics shareInstance] logError:@"CRASH" parameters:@{ JsonKeyErrorST: userInfo}];
}
}
- (void)handleNSException:(NSDictionary*)userInfo
{
NSLog(@"crash============:\n%@", userInfo);
NSLog(@"crash============:\n%@", userInfo);
if (userInfo) {
[[YH_Analytics shareInstance]logError:@"CRASH" parameters:@{ JsonKeyErrorST: userInfo}];
[[YH_Analytics shareInstance] logError:@"CRASH" parameters:@{ JsonKeyErrorST: userInfo}];
}
}
... ...
... ... @@ -127,6 +127,10 @@ static dispatch_queue_t persisitingQueue;
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Properties
... ...
... ... @@ -11,7 +11,10 @@
#import "OCMock.h"
#import "NSString+YHAnalytics.h"
@interface NSString_YHAnalyticsTests : XCTestCase
@interface NSString_YHAnalyticsTests : XCTestCase {
@private
id mock;
}
@end
... ... @@ -20,16 +23,29 @@
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
NSLog(@"%@ setUp", self.name);
mock = [OCMockObject mockForClass:[NSString class]];
XCTAssertNotNil(mock, @"Cannot create NSString mock");
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
NSLog(@"%@ tearDown", self.name);
}
- (void)testMd5Method {
NSLog(@"%@ start", self.name);
[[mock stub] md5];
[mock md5];
NSLog(@"%@ end", self.name);
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
- (void)testUrlDecodedStringMethod {
NSLog(@"%@ start", self.name);
[[mock stub] urlDecodedString];
[mock urlDecodedString];
NSLog(@"%@ end", self.name);
}
@end
... ...
... ... @@ -11,7 +11,10 @@
#import "OCMock.h"
#import "YHCrashReporter.h"
@interface YHCrashReporterTests : XCTestCase
@interface YHCrashReporterTests : XCTestCase{
@private
id mock;
}
@end
... ... @@ -20,6 +23,9 @@
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
NSLog(@"%@ setUp", self.name);
mock = [OCMockObject mockForClass:[YHCrashReporter class]];
XCTAssertNotNil(mock, @"Cannot create YHCrashReporter mock");
}
- (void)tearDown {
... ...
... ... @@ -25,7 +25,7 @@
// Put setup code here. This method is called before the invocation of each test method in the class.
NSLog(@"%@ setUp", self.name);
mock = [OCMockObject mockForClass:[YH_Analytics class]];
XCTAssertNotNil(mock, @"Cannot create YH_Analytics instance");
XCTAssertNotNil(mock, @"Cannot create YH_Analytics mock");
}
- (void)tearDown {
... ... @@ -34,6 +34,8 @@
NSLog(@"%@ tearDown", self.name);
}
#pragma mark - 方法存在性验证
- (void)testStartWithAppIdMethodWithConstraint {
NSLog(@"%@ start", self.name); // self.name is the name of the test-case method.
... ...