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 (Swift)

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

  1. Follow the same steps as for the Objective-C setup, but choose Swift when prompted to choose a language.
  2. Make sure that a Bridging Header file has also been created (Xcode will usually prompt you to create one if this is your first Swift file in the project).
  3. Import <CavyNativeReporter/CavyNativeReporter.h> in your Bridging Header.
  4. Write a test.

The following Swift code is equivalent to the Objective-C example:

import XCTest

class BridgeTest: XCTestCase {
  func testBridge() {
    let expectation = XCTestExpectation(description: "Cavy tests passed")

    CavyNativeReporter.onFinish { report in
      NSLog("%@", report)
      let errorCount = report["errorCount"] as? Int ?? 0
      if errorCount > 0 {
        XCTFail("Cavy tests had one or more errors")
      }
      expectation.fulfill()
    }

    wait(for: [expectation], timeout: 5)
  }
}

See also

API reference

  • onFinish

Useful links for iOS Testing

  • Writing XCTest classes
  • Running tests
  • Overview of testing with XCTest
← iOS XCTest example (Obj-C)Android example (JUnit) →
Pixie Labs
Docs
Getting StartedGuidesAPI Reference
Community
HelpContributorsFurther reading
More
GitHub
StarFollow @pixielabsTweet
Cavy
Copyright © 2021 Pixie Labs