Skip to content

Commit

Permalink
Printing out location of HTML test failures on each failed test suite (
Browse files Browse the repository at this point in the history
…#29)

This is a work around for #28
Also, updating the Sample app to Xcode 2.3
  • Loading branch information
plivesey authored Sep 22, 2016
1 parent 1b1ef12 commit 56cf751
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 27 deletions.
23 changes: 23 additions & 0 deletions LayoutTest/TestCase/LYTLayoutFailingTestSnapshotRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ @interface LYTLayoutFailingTestSnapshotRecorder ()

@property (nonatomic) Class invocationClass;
@property (nonatomic) NSMutableSet *failingTestsSnapshotFolders;
@property (nonatomic) NSInteger failedTestsDuringTestSuite;

@end

@implementation LYTLayoutFailingTestSnapshotRecorder

+ (void)initialize {
[LYTLayoutFailingTestSnapshotRecorder sharedInstance];
}

+ (instancetype)sharedInstance {
static LYTLayoutFailingTestSnapshotRecorder *sharedInstance = nil;
static dispatch_once_t onceToken;
Expand All @@ -69,12 +74,29 @@ - (instancetype)init {
return self;
}

- (void)testSuiteWillStart:(XCTestSuite *)testSuite {
self.failedTestsDuringTestSuite = 0;
}

- (void)testSuiteDidFinish:(XCTestSuite *)testSuite {
if (self.failedTestsDuringTestSuite > 0 && self.failingTestsSnapshotFolders.count > 0) {
SimpleLog(@"\nSnapshots of failing tests can be found in:\n");
for (NSString *path in self.failingTestsSnapshotFolders) {
SimpleLog(@"%@\n", path);
}
SimpleLog(@"\n");
}
}

- (void)testBundleDidFinish:(NSBundle *)testBundle {
// NOTE: For some reason, this never gets called
// See #28 on Github
if (self.failingTestsSnapshotFolders.count > 0) {
SimpleLog(@"\nSnapshots of failing tests can be found in:\n");
for (NSString *path in self.failingTestsSnapshotFolders) {
SimpleLog(@"%@\n", path);
}
SimpleLog(@"\n");
[self.failingTestsSnapshotFolders removeAllObjects];
}
}
Expand All @@ -84,6 +106,7 @@ - (void)testCase:(XCTestCase *)testCase didFailWithDescription:(NSString *)descr
NSString *pathForSnapshots = [self commonRootPathForInvocationClass:[testCase class]];
pathForSnapshots = [pathForSnapshots stringByAppendingString:@"/index.html"];
[self.failingTestsSnapshotFolders addObject:pathForSnapshots];
self.failedTestsDuringTestSuite += 1;
}
}

Expand Down
15 changes: 13 additions & 2 deletions SampleApp/Podfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
use_frameworks!

pod 'LayoutTestBase', :path => '..'

target :SampleApp do
pod 'LayoutTestBase', :path => '..'
end

target :CatalogSample do
pod 'LayoutTestBase', :path => '..'
end

target :SampleAppTests do
pod 'LayoutTest/Swift', :path => '..'
end

# This is necessary to convert the target to swift 2.3
# This isn't detected automatically by cocoapods or supported in the podspec
# We can remove this once Cocoapods has a better solution
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3'
end
end
end

44 changes: 22 additions & 22 deletions SampleApp/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
PODS:
- LayoutTest/ModuleHeader (1.2.1):
- LayoutTestBase (= 1.2.1)
- LayoutTest/Swift (1.2.1):
- LayoutTest/ModuleHeader (1.3.0):
- LayoutTestBase (= 1.3.0)
- LayoutTest/Swift (1.3.0):
- LayoutTest/ModuleHeader
- LayoutTest/SwiftSubspec
- LayoutTest/TestCase
- LayoutTestBase (= 1.2.1)
- LayoutTestBase (= 1.3.0)
- LayoutTestBase/Autolayout
- LayoutTestBase/Catalog
- LayoutTestBase/Config
- LayoutTestBase/Core
- LayoutTestBase/UIViewHelpers
- LayoutTest/SwiftSubspec (1.2.1):
- LayoutTest/SwiftSubspec (1.3.0):
- LayoutTest/ModuleHeader
- LayoutTest/TestCase
- LayoutTestBase (= 1.2.1)
- LayoutTest/TestCase (1.2.1):
- LayoutTestBase (= 1.3.0)
- LayoutTest/TestCase (1.3.0):
- LayoutTest/ModuleHeader
- LayoutTestBase (= 1.2.1)
- LayoutTestBase (= 1.3.0)
- LayoutTestBase/Config
- LayoutTestBase/Core
- LayoutTestBase (1.2.1):
- LayoutTestBase/Autolayout (= 1.2.1)
- LayoutTestBase/Catalog (= 1.2.1)
- LayoutTestBase/Config (= 1.2.1)
- LayoutTestBase/Core (= 1.2.1)
- LayoutTestBase/UIViewHelpers (= 1.2.1)
- LayoutTestBase/Autolayout (1.2.1)
- LayoutTestBase/Catalog (1.2.1):
- LayoutTestBase (1.3.0):
- LayoutTestBase/Autolayout (= 1.3.0)
- LayoutTestBase/Catalog (= 1.3.0)
- LayoutTestBase/Config (= 1.3.0)
- LayoutTestBase/Core (= 1.3.0)
- LayoutTestBase/UIViewHelpers (= 1.3.0)
- LayoutTestBase/Autolayout (1.3.0)
- LayoutTestBase/Catalog (1.3.0):
- LayoutTestBase/Core
- LayoutTestBase/Config (1.2.1)
- LayoutTestBase/Core (1.2.1):
- LayoutTestBase/Config (1.3.0)
- LayoutTestBase/Core (1.3.0):
- LayoutTestBase/Config
- LayoutTestBase/UIViewHelpers (1.2.1):
- LayoutTestBase/UIViewHelpers (1.3.0):
- LayoutTestBase/Config

DEPENDENCIES:
Expand All @@ -46,9 +46,9 @@ EXTERNAL SOURCES:
:path: ..

SPEC CHECKSUMS:
LayoutTest: 55dbb73093fe424107895c1e52e7cf506b8183cb
LayoutTestBase: 5564ede8f8f7a6c8d9fb37874048dbc4115c577c
LayoutTest: d03e54adfec57236f0f44e4d3b2b905731516dde
LayoutTestBase: f5286c3751065de5eb42e8a1f781237c5b5c6eef

PODFILE CHECKSUM: a8facff5fad656f6e0450da6179999d82b6baaa4
PODFILE CHECKSUM: 3f2420eb489cc0f10b880a3af950f8701bc45d05

COCOAPODS: 1.0.1
15 changes: 14 additions & 1 deletion SampleApp/SampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0710;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
61A305DF1C12583100CB3FEC = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
};
61A305F31C12583100CB3FEC = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
TestTargetID = 61A305DF1C12583100CB3FEC;
};
61F42D701C18878700A21677 = {
Expand Down Expand Up @@ -530,8 +532,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -574,8 +578,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -594,6 +600,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -608,6 +615,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LinkedIn.SampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -621,18 +629,21 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LinkedIn.SampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Release;
};
61A306011C12583100CB3FEC /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 31D5AE608C90EDC0A3FF524E /* Pods-SampleAppTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = SampleAppTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LinkedIn.SampleAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleApp.app/SampleApp";
};
name = Debug;
Expand All @@ -641,11 +652,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 515CB4D861431423FB11B475 /* Pods-SampleAppTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = SampleAppTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LinkedIn.SampleAppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleApp.app/SampleApp";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp/SampleFailingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SampleFailingView: UIView {
@IBOutlet weak var button: UIButton!

class func loadFromNib() -> SampleFailingView {
return NSBundle.mainBundle().loadNibNamed(SampleFailingView.nibName, owner: nil, options: nil)[0] as! SampleFailingView
return NSBundle.mainBundle().loadNibNamed(SampleFailingView.nibName, owner: nil, options: nil)![0] as! SampleFailingView
}

func setup(json: [NSObject: AnyObject]) {
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp/SampleTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SampleTableViewCell: UITableViewCell {
}

class func loadFromNib() -> SampleTableViewCell {
return NSBundle.mainBundle().loadNibNamed(SampleTableViewCell.nibName, owner: nil, options: nil)[0] as! SampleTableViewCell
return NSBundle.mainBundle().loadNibNamed(SampleTableViewCell.nibName, owner: nil, options: nil)![0] as! SampleTableViewCell
}

func setup(json: [NSObject: AnyObject]) {
Expand Down

0 comments on commit 56cf751

Please sign in to comment.