File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -221,13 +221,30 @@ void XCTestMethod(XCTestCase* self, SEL _cmd) {
221
221
int parts = result->total_part_count ();
222
222
for (int i = 0 ; i < parts; i++) {
223
223
const testing::TestPartResult& part = result->GetTestPartResult (i);
224
- [self
225
- recordFailureWithDescription: @(part.message ())
226
- inFile: @(part.file_name () ? part.file_name () : " " )
227
- atLine: (part.line_number () > 0
228
- ? part.line_number ()
229
- : 0 )
230
- expected: true ];
224
+ const char * path = part.file_name () ? part.file_name () : " " ;
225
+ int line = part.line_number () > 0 ? part.line_number () : 0 ;
226
+
227
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
228
+ // Xcode 12
229
+ auto * location = [[XCTSourceCodeLocation alloc ] initWithFilePath: @(path)
230
+ lineNumber: line];
231
+ auto * context = [[XCTSourceCodeContext alloc ] initWithLocation: location];
232
+ auto * issue = [[XCTIssue alloc ] initWithType: XCTIssueTypeAssertionFailure
233
+ compactDescription: @(part.summary ())
234
+ detailedDescription: @(part.message ())
235
+ sourceCodeContext: context
236
+ associatedError: nil
237
+ attachments: @[]];
238
+ [self recordIssue: issue];
239
+
240
+ #else
241
+ // Xcode 11 and prior. recordFailureWithDescription:inFile:atLine:expected:
242
+ // is deprecated in Xcode 12.
243
+ [self recordFailureWithDescription: @(part.message ())
244
+ inFile: @(path)
245
+ atLine: line
246
+ expected: true ];
247
+ #endif
231
248
}
232
249
}
233
250
You can’t perform that action at this time.
0 commit comments