Last active
December 5, 2019 14:16
-
-
Save jmoody/3f8a456eef395ff6dc8d1265f8271ff5 to your computer and use it in GitHub Desktop.
Add a step and a screenshot to your Test Cloud report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <XCTest/XCTest.h> | |
#import "Screenshotter.h" | |
@implementation Screenshotter | |
+ (void)screenshotWithTitle:(NSString *)format, ... { | |
NSString *title = nil; | |
va_list args; | |
va_start(args, format); | |
title = [[NSString alloc] initWithFormat:format arguments:args]; | |
va_end(args); | |
[XCTContext | |
runActivityNamed:title | |
block:^(id<XCTActivity> _Nonnull activity) { | |
XCUIScreenshot *screenshot = [[XCUIScreen mainScreen] screenshot]; | |
XCTAttachment *attachment; | |
attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; | |
[attachment setLifetime:XCTAttachmentLifetimeKeepAlways]; | |
[activity addAttachment:attachment]; | |
}]; | |
} | |
+ (void)addScreenshotToActivity:(id<XCTActivity> _Nonnull ) activity; { | |
XCUIScreenshot *screenshot = [[XCUIScreen mainScreen] screenshot]; | |
XCTAttachment *attachment; | |
attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; | |
[attachment setLifetime:XCTAttachmentLifetimeKeepAlways]; | |
[activity addAttachment:attachment]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment