Swift Collectors

Test Analytics ships with Swift collectors :github: test-collector-swift, and more coming soon.

You can also upload test results by importing JSON or JUnit XML.


XCTest is a test framework to write unit tests for your Xcode projects.

Before you start, make sure XCTest runs with access to CI environment variables.

  1. Create a test suite and copy the test suite API token.

  2. Securely set the BUILDKITE_ANALYTICS_TOKEN secret on your CI to the API token from the previous step.

    If you're testing an Xcode project, note that Xcode doesn't automatically pass environment variables to the test runner, so you need to add them manually. In your test scheme or test plan, go to the Environment Variables section and add the following key-value pair:

  3. In the Package.swift file, add https://github.com/buildkite/test-collector-swift to the dependencies and add BuildkiteTestCollector to any test target requiring analytics:

    let package = Package(
      name: "MyProject",
      dependencies: [
        .package(url: "https://github.com/buildkite/test-collector-swift", from: "0.3.0")
      targets: [
        .target(name: "MyProject"),
          name: "MyProjectTests",
          dependencies: [
            .product(name: "BuildkiteTestCollector", package: "test-collector-swift")
  4. Commit and push your changes:

    git checkout -b add-buildkite-test-analytics
    git commit -am "Add Buildkite Test Analytics"
    git push origin add-buildkite-test-analytics

Once you're done, in your Test Analytics dashboard, you'll see analytics of test executions on all branches that include this code.

If you don't see branch names, build numbers, or commit hashes in Test Analytics, then read CI Environments to learn more about exporting your environment to the collector.


To enable debugging output, set the BUILDKITE_ANALYTICS_DEBUG_ENABLED environment variable to true.