Reporting to iOS XCTest (Objective C)
To set up your own XCTestCase that makes use of cavy-native-reporter:
- Open your project's .xcodeproj(or.xcworkspace) in Xcode.
- In the Project navigator view, navigate to the folder containing your XCTest test cases.
- Create a new test case (select New File -> Unit Test Case Class).
- Import <CavyNativeReporter/CavyNativeReporter.h>
- Write a test.
Taking the sample app as an example, we have an XCTestCase BridgeTest which
waits for Cavy tests to run and fails if any test returns an error:
#import <XCTest/XCTest.h>
#import <CavyNativeReporter/CavyNativeReporter.h>
@interface BridgeTest : XCTestCase
@end
@implementation BridgeTest
- (void)testBridge {
  // Make a new expectation.
  XCTestExpectation *expectation = [[XCTestExpectation alloc] initWithDescription: @"Cavy tests passed"];
  [CavyNativeReporter onFinishWithBlock: ^void(NSDictionary* report) {
    // Pull the error count from the report object.
    long errorCount = [report[@"errorCount"] integerValue];
    // Fail if there are errors.
    if (errorCount > 0) {
      XCTFail(@"Cavy tests had one or more errors");
    }
    // Fulfill the expectation.
    [expectation fulfill];
  }];
  // Wait for expectation to fulfill.
  [self waitForExpectations:@[expectation] timeout:100];
}
@end