Skip to content

Commit 953d06e

Browse files
authored
[iOS] Unit Test Logging Update (#6844)
* Updated Unit Test Error messages * added test file -revert this commit in the future * updated logging * Revert "added test file -revert this commit in the future" This reverts commit 4d7f19b.
1 parent 9e97494 commit 953d06e

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,35 +200,47 @@ - (void)parseAndRenderDFS:(NSString *)rootPath FileManager:(NSFileManager *)fMan
200200
if ([_setOfExpectedToFailFiles containsObject:fileName]) {
201201
XCTAssertFalse(cardParseResult.isValid);
202202
} else {
203-
if (!cardParseResult.isValid) {
204-
NSException *e = [NSException exceptionWithName:@"ParseFailed" reason:@"Parsing Failed" userInfo:nil];
205-
@throw e;
206-
}
207-
XCTAssertTrue(cardParseResult.isValid);
203+
[self assertParsing:cardParseResult fileName:fileName];
208204
ACRRenderResult *renderResult;
209205
@try {
210206
renderResult = [ACRRenderer render:cardParseResult.card
211207
config:nil
212208
widthConstraint:300
213209
delegate:nil];
214-
XCTAssertTrue(renderResult.succeeded);
210+
[self assertRendering:renderResult fileName:fileName];
215211
}
216212
@catch (NSException *exception) {
217-
NSString *exceptionMessage = [NSString stringWithFormat:@"%@", exception];
218-
printf("Render Failed while rendering %s\n%s", [fileName UTF8String], [exceptionMessage UTF8String]);
219-
XCTAssertTrue(NO);
213+
XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@"Rendering Exception in %@", fileName]];
214+
[self recordIssue:issue];
220215
}
221216
}
222217
}
223218
@catch (NSException *exception) {
224-
printf("Parsing Failed %s\n", [fileName UTF8String]);
225-
for (NSError *parseError in cardParseResult.parseErrors) {
226-
printf("%s\n", [parseError.userInfo[NSLocalizedDescriptionKey] UTF8String]);
227-
}
228-
XCTAssertTrue(NO);
219+
[self assertParsing:cardParseResult fileName:fileName];
220+
}
221+
}
222+
}
223+
224+
- (void)assertParsing:(ACOAdaptiveCardParseResult *)parseResult fileName:(NSString *)fileName
225+
{
226+
if (!parseResult.isValid) {
227+
NSMutableArray<NSString *> *errorMsgs = [[NSMutableArray alloc] init];
228+
for (NSError *parseError in parseResult.parseErrors) {
229+
[errorMsgs addObject:parseError.userInfo[NSLocalizedDescriptionKey]];
229230
}
231+
XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@" %@ in %@", [errorMsgs componentsJoinedByString:@", "], fileName]];
232+
[self recordIssue:issue];
233+
}
234+
}
235+
236+
- (void)assertRendering:(ACRRenderResult *)renderResult fileName:(NSString *)fileName
237+
{
238+
if (!renderResult.succeeded) {
239+
XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@"Rendering Failure in %@", fileName]];
240+
[self recordIssue:issue];
230241
}
231242
}
243+
232244
- (void)testParsingAndRenderingAllCards
233245
{
234246
NSBundle *main = [NSBundle mainBundle];

0 commit comments

Comments
 (0)