Improve test logging.

pull/1/head
Matthew Chen 7 years ago
parent 79ed05133c
commit c6ef7f18e7

@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setUp - (void)setUp
{ {
NSLog(@"%@ setUp", self.logTag); OWSLogInfo(@"");
[super setUp]; [super setUp];
@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tearDown - (void)tearDown
{ {
NSLog(@"%@ tearDown", self.logTag); OWSLogInfo(@"");
[super tearDown]; [super tearDown];
} }

@ -156,7 +156,7 @@ NS_ASSUME_NONNULL_BEGIN
[self waitForExpectationsWithTimeout:5.0 [self waitForExpectationsWithTimeout:5.0
handler:^(NSError *error) { handler:^(NSError *error) {
if (error) { if (error) {
NSLog(@"Timeout Error: %@", error); OWSLogInfo(@"Timeout Error: %@", error);
} }
}]; }];
} }

@ -103,7 +103,7 @@
NSDateFormatter *formatter = [NSDateFormatter new]; NSDateFormatter *formatter = [NSDateFormatter new];
formatter.dateStyle = NSDateFormatterLongStyle; formatter.dateStyle = NSDateFormatterLongStyle;
formatter.timeStyle = NSDateFormatterLongStyle; formatter.timeStyle = NSDateFormatterLongStyle;
NSLog(@"now: %@", [formatter stringFromDate:now]); OWSLogInfo(@"now: %@", [formatter stringFromDate:now]);
NSDate *oneSecondAgo = NSDate *oneSecondAgo =
[NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] - kSecondInterval]; [NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] - kSecondInterval];
@ -135,7 +135,7 @@
NSDate *twoYearsAhead = NSDate *twoYearsAhead =
[NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] + kYearInterval * 2]; [NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] + kYearInterval * 2];
NSLog(@"oneSecondAgo: %@", [formatter stringFromDate:oneSecondAgo]); OWSLogInfo(@"oneSecondAgo: %@", [formatter stringFromDate:oneSecondAgo]);
XCTAssertTrue([DateUtil dateIsToday:oneSecondAgo now:now]); XCTAssertTrue([DateUtil dateIsToday:oneSecondAgo now:now]);
XCTAssertTrue([DateUtil dateIsToday:oneMinuteAgo now:now]); XCTAssertTrue([DateUtil dateIsToday:oneMinuteAgo now:now]);
@ -236,13 +236,13 @@
formatter.timeStyle = NSDateFormatterLongStyle; formatter.timeStyle = NSDateFormatterLongStyle;
NSDate *yesterdayBeforeMidnight = [self dateWithYear:2015 month:8 day:10 hour:23 minute:55]; NSDate *yesterdayBeforeMidnight = [self dateWithYear:2015 month:8 day:10 hour:23 minute:55];
NSLog(@"yesterdayBeforeMidnight: %@", [formatter stringFromDate:yesterdayBeforeMidnight]); OWSLogInfo(@"yesterdayBeforeMidnight: %@", [formatter stringFromDate:yesterdayBeforeMidnight]);
NSDate *todayAfterMidnight = [self dateWithYear:2015 month:8 day:11 hour:0 minute:5]; NSDate *todayAfterMidnight = [self dateWithYear:2015 month:8 day:11 hour:0 minute:5];
NSLog(@"todayAfterMidnight: %@", [formatter stringFromDate:todayAfterMidnight]); OWSLogInfo(@"todayAfterMidnight: %@", [formatter stringFromDate:todayAfterMidnight]);
NSDate *todayNoon = [self dateWithYear:2015 month:8 day:11 hour:12 minute:0]; NSDate *todayNoon = [self dateWithYear:2015 month:8 day:11 hour:12 minute:0];
NSLog(@"todayNoon: %@", [formatter stringFromDate:todayNoon]); OWSLogInfo(@"todayNoon: %@", [formatter stringFromDate:todayNoon]);
// Before Midnight, after Midnight. // Before Midnight, after Midnight.
XCTAssertFalse([DateUtil dateIsToday:yesterdayBeforeMidnight now:todayAfterMidnight]); XCTAssertFalse([DateUtil dateIsToday:yesterdayBeforeMidnight now:todayAfterMidnight]);

@ -12,27 +12,27 @@ NS_ASSUME_NONNULL_BEGIN
- (void)receivedOffer:(SSKProtoCallMessageOffer *)offer fromCallerId:(NSString *)callerId - (void)receivedOffer:(SSKProtoCallMessageOffer *)offer fromCallerId:(NSString *)callerId
{ {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)receivedAnswer:(SSKProtoCallMessageAnswer *)answer fromCallerId:(NSString *)callerId - (void)receivedAnswer:(SSKProtoCallMessageAnswer *)answer fromCallerId:(NSString *)callerId
{ {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)receivedIceUpdate:(SSKProtoCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId - (void)receivedIceUpdate:(SSKProtoCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId
{ {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)receivedHangup:(SSKProtoCallMessageHangup *)hangup fromCallerId:(NSString *)callerId - (void)receivedHangup:(SSKProtoCallMessageHangup *)hangup fromCallerId:(NSString *)callerId
{ {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)receivedBusy:(SSKProtoCallMessageBusy *)busy fromCallerId:(NSString *)callerId - (void)receivedBusy:(SSKProtoCallMessageBusy *)busy fromCallerId:(NSString *)callerId
{ {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
@end @end

@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
//- (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error //- (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error
//{ //{
// NSLog(@"[OWSFakeContactsUpdater] Faking contact lookup."); // OWSLogInfo(@"[OWSFakeContactsUpdater] Faking contact lookup.");
// return [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id" // return [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id"
// relay:nil]; // relay:nil];
//} //}

@ -14,22 +14,22 @@ NS_ASSUME_NONNULL_BEGIN
inThread:(TSThread *)thread inThread:(TSThread *)thread
contactsManager:(id<ContactsManagerProtocol>)contactsManager contactsManager:(id<ContactsManagerProtocol>)contactsManager
transaction:(YapDatabaseReadTransaction *)transaction { transaction:(YapDatabaseReadTransaction *)transaction {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)notifyUserForErrorMessage:(TSErrorMessage *)error - (void)notifyUserForErrorMessage:(TSErrorMessage *)error
thread:(TSThread *)thread thread:(TSThread *)thread
transaction:(YapDatabaseReadWriteTransaction *)transaction { transaction:(YapDatabaseReadWriteTransaction *)transaction {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)error - (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)error
transaction:(YapDatabaseReadWriteTransaction *)transaction { transaction:(YapDatabaseReadWriteTransaction *)transaction {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
- (void)clearAllNotifications { - (void)clearAllNotifications {
NSLog(@"%s", __PRETTY_FUNCTION__); OWSLogInfo(@"");
} }
@end @end

@ -20,7 +20,7 @@
success:(void (^)())successCallback success:(void (^)())successCallback
failure:(void (^)(NSError *))failureCallback failure:(void (^)(NSError *))failureCallback
{ {
NSLog(@"faking successful provisioning"); OWSLogInfo(@"faking successful provisioning");
successCallback(); successCallback();
} }
@ -35,7 +35,7 @@
- (void)requestProvisioningCodeWithSuccess:(void (^)(NSString *))successCallback - (void)requestProvisioningCodeWithSuccess:(void (^)(NSString *))successCallback
failure:(void (^)(NSError *))failureCallback failure:(void (^)(NSError *))failureCallback
{ {
NSLog(@"faking successful provisioning code fetching"); OWSLogInfo(@"faking successful provisioning code fetching");
successCallback(@"fake-provisioning-code"); successCallback(@"fake-provisioning-code");
} }
@ -90,7 +90,7 @@
[self waitForExpectationsWithTimeout:5.0 [self waitForExpectationsWithTimeout:5.0
handler:^(NSError *error) { handler:^(NSError *error) {
if (error) { if (error) {
NSLog(@"Timeout Error: %@", error); OWSLogInfo(@"Timeout Error: %@", error);
} }
}]; }];
} }

@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
[self waitForExpectationsWithTimeout:5 [self waitForExpectationsWithTimeout:5
handler:^(NSError *error) { handler:^(NSError *error) {
NSLog(@"No message submitted."); OWSLogInfo(@"No message submitted.");
}]; }];
} }

@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
forRecipient:(SignalRecipient *)recipient forRecipient:(SignalRecipient *)recipient
inThread:(TSThread *)thread inThread:(TSThread *)thread
{ {
NSLog(@"[OWSFakeMessagesManager] Faking deviceMessages."); OWSLogInfo(@"[OWSFakeMessagesManager] Faking deviceMessages.");
return @[]; return @[];
} }
@ -298,7 +298,7 @@ NS_ASSUME_NONNULL_BEGIN
[self waitForExpectationsWithTimeout:5 [self waitForExpectationsWithTimeout:5
handler:^(NSError *error) { handler:^(NSError *error) {
NSLog(@"Expiration timer not set in time."); OWSLogInfo(@"Expiration timer not set in time.");
}]; }];
} }
@ -324,7 +324,7 @@ NS_ASSUME_NONNULL_BEGIN
[self waitForExpectationsWithTimeout:5 [self waitForExpectationsWithTimeout:5
handler:^(NSError *error) { handler:^(NSError *error) {
NSLog(@"Expiration timer not set in time."); OWSLogInfo(@"Expiration timer not set in time.");
}]; }];
} }

@ -7,6 +7,9 @@
#import "SSKEnvironment.h" #import "SSKEnvironment.h"
#import "TestAppContext.h" #import "TestAppContext.h"
@import CocoaLumberjack;
#import <CocoaLumberjack/DDTTYLogger.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG #ifdef DEBUG
@ -15,10 +18,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setUp - (void)setUp
{ {
NSLog(@"%@ setUp", self.logTag); OWSLogInfo(@"%@ setUp", self.logTag);
[super setUp]; [super setUp];
[DDLog addLogger:DDTTYLogger.sharedInstance];
ClearCurrentAppContextForTests(); ClearCurrentAppContextForTests();
SetCurrentAppContext([TestAppContext new]); SetCurrentAppContext([TestAppContext new]);
@ -27,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tearDown - (void)tearDown
{ {
NSLog(@"%@ tearDown", self.logTag); OWSLogInfo(@"%@ tearDown", self.logTag);
[super tearDown]; [super tearDown];
} }

@ -4,6 +4,7 @@
import XCTest import XCTest
import SignalServiceKit import SignalServiceKit
import CocoaLumberjack
@objc @objc
public class SSKBaseTestSwift: XCTestCase { public class SSKBaseTestSwift: XCTestCase {
@ -12,6 +13,8 @@ public class SSKBaseTestSwift: XCTestCase {
public override func setUp() { public override func setUp() {
super.setUp() super.setUp()
DDLog.add(DDTTYLogger.sharedInstance)
ClearCurrentAppContextForTests() ClearCurrentAppContextForTests()
SetCurrentAppContext(TestAppContext()) SetCurrentAppContext(TestAppContext())

Loading…
Cancel
Save