FBFailureProofTestCase.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import "FBFailureProofTestCase.h"
  10. #import "FBLogger.h"
  11. @implementation FBFailureProofTestCase
  12. - (void)setUp
  13. {
  14. [super setUp];
  15. self.continueAfterFailure = YES;
  16. // https://github.com/appium/appium/issues/13949
  17. self.shouldSetShouldHaltWhenReceivesControl = NO;
  18. self.shouldHaltWhenReceivesControl = NO;
  19. }
  20. - (void)_recordIssue:(XCTIssue *)issue
  21. {
  22. NSString *description = [NSString stringWithFormat:@"%@ (%@)", issue.compactDescription, issue.associatedError.description];
  23. [FBLogger logFmt:@"Issue type: %ld", issue.type];
  24. [self _enqueueFailureWithDescription:description
  25. inFile:issue.sourceCodeContext.location.fileURL.path
  26. atLine:issue.sourceCodeContext.location.lineNumber
  27. // 5 == XCTIssueTypeUnmatchedExpectedFailure
  28. expected:issue.type == 5];
  29. }
  30. - (void)_recordIssue:(XCTIssue *)issue forCaughtError:(id)error
  31. {
  32. [self _recordIssue:issue];
  33. }
  34. - (void)recordIssue:(XCTIssue *)issue
  35. {
  36. [self _recordIssue:issue];
  37. }
  38. /**
  39. Override 'recordFailureWithDescription' to not stop by failures.
  40. */
  41. - (void)recordFailureWithDescription:(NSString *)description
  42. inFile:(NSString *)filePath
  43. atLine:(NSUInteger)lineNumber
  44. expected:(BOOL)expected
  45. {
  46. [self _enqueueFailureWithDescription:description inFile:filePath atLine:lineNumber expected:expected];
  47. }
  48. /**
  49. Private XCTestCase method used to block and tunnel failure messages
  50. */
  51. - (void)_enqueueFailureWithDescription:(NSString *)description
  52. inFile:(NSString *)filePath
  53. atLine:(NSUInteger)lineNumber
  54. expected:(BOOL)expected
  55. {
  56. [FBLogger logFmt:@"Enqueue Failure: %@ %@ %lu %d", description, filePath, (unsigned long)lineNumber, expected];
  57. // TODO: Figure out which error types we want to escalate
  58. }
  59. @end