Cavy

Cavy

  • Documentation
  • API
  • GitHub
  • Roadmap
  • FAQ

›Cavy Native Reporter

Getting Started

  • Installing
  • Setting up the Cavy Tester
  • Writing tests

    • Hooking up components
    • Writing test cases
  • Running tests
  • Sample app

API reference

  • Tester Component
  • Test Hooks
  • Test Helpers
  • CLI Commands
  • Filtering tests
  • Cavy Native Reporter

Guides

  • Specifing a custom app entry point
  • Writing your own spec helpers
  • Writing your own custom reporter
  • Cavy Native Reporter

    • Using Cavy Native Reporter
    • iOS XCTest example (Obj-C)
    • iOS XCTest example (Swift)
    • Android example (JUnit)

Reporting to iOS XCTest (Objective C)

To set up your own XCTestCase that makes use of cavy-native-reporter:

  1. Open your project's .xcodeproj (or .xcworkspace) in Xcode.
  2. In the Project navigator view, navigate to the folder containing your XCTest test cases.
  3. Create a new test case (select New File -> Unit Test Case Class).
  4. Import <CavyNativeReporter/CavyNativeReporter.h>
  5. 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

See also

API reference

  • onFinishWithBlock

Useful links for iOS Testing

  • Writing XCTest classes
  • Running tests
  • Overview of testing with XCTest
← Using Cavy Native ReporteriOS XCTest example (Swift) →
Pixie Labs
Docs
Getting StartedGuidesAPI Reference
Community
HelpContributorsFurther reading
More
GitHub
StarFollow @pixielabsTweet
Cavy
Copyright © 2021 Pixie Labs