Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

An Xcode test engine for use with Phabricator's arc command line tool.

License

Notifications You must be signed in to change notification settings

google/arc-xcode-test-engine

xcode-test-engine for arc

xcode-test-engine is a test engine for use with Phabricator's arc command line tool.

Features

xcode-test-engine presently works well with projects that have a single root workspace and a single unit test target.

Supports arc unit:

~ $ arc unit
   PASS   42ms★  MyTests::Test1
   PASS    3ms★  MyTests::Test2
   PASS    2ms★  MyTests::Test3
   PASS    2ms★  MyTests::Test4
   PASS    1ms★  MyTests::Test5

And arc unit --coverage:

~ $ arc unit --coverage
COVERAGE REPORT
      5%     src/Widget.m
     18%     src/SomeDirectory/AnotherWidget.m
     69%     src/SomeDirectory/WidgetBuilder.m
     80%     src/Controller/WidgetViewController.m
     93%     src/Controller/WidgetTableViewController.m

Installation

Project-specific

Add this repository as a git submodule.

git submodule init
git submodule add <url for this repo>

Your .arcconfig should list xcode-test-engine in the load configuration:

{
  "load": [
    "path/to/arc-xcode-test-engine"
  ]
}

Global

Clone this repository to the same directory where arcanist and libphutil are globally located. Your directory structure will look like so:

arcanist/
libphutil/
arc-xcode-test-engine/

Your .arcconfig should list arc-xcode-test-engine in the load configuration (without a path):

{
  "load": [
    "arc-xcode-test-engine"
  ]
}

Usage

Create a .arcunit file in the root of your project and add the following content:

{
  "engines": {
    "xcode": {
      "type": "xcode-test-engine",
      "include": "(\\.(m|h|mm|swift)$)",
      "exclude": "(/Pods/)"
    }
  }
}

Feel free to change the include/exclude regexes to suit your project's needs.

Now modify your .arcconfig file by adding the following configuration:

{
  "unit.xcode": {
    "build": {
      "workspace": "path/to/Workspace.xcworkspace",
      "scheme": "UnitTestsScheme",
      "configuration": "Debug",
      "destination": "platform=iOS Simulator,name=iPhone 6S"
    },
    "coverage": {
      "product": "SomeFramework.framework/SomeFramework"
    }
  }
}

Configuration options

Build configuration options

Any value provided to "build" will be passed along to xcodebuild as a flag.

"unit.xcode": {
  "build": { ... }
}

Picking the coverage product

Provide the path to the product for which coverage should be calculated. If building a library/framework this might be the framework binary product.

"unit.xcode": {
  "coverage": {
    "product": " ... "
  }
}

Pre-build commands

Some projects require a pre-build script that runs before the xcodebuild command.

"unit.xcode": {
  "pre-build": "execute this command before the build step"
}

For example, CocoaPods projects may need to be re-generated.

  "pre-build": "pod install --project-directory=path/ --no-repo-update"

Supporting multiple test engines

We support Arcanist's multi test engine extension. Visit the [extension]((https://github.com/tagview/arcanist-extensions#multi_test_engine) page to learn more about it.

Your .arcconfig file will have something similar to the following configuration:

{
  "unit.engine": "MultiTestEngine",
  "unit.engine.multi-test.engines": [
    {
      "engine": "XcodeUnitTestEngine",
      "unit.engine.xcode.config": {
        "build": {
          "workspace": "YourWorkSpace.xcworkspace",
          "scheme": "Scheme1",
          "configuration": "Debug",
          "destination": "platform=iOS Simulator,name=iPhone SE"
        },
        "coverage": {
          "product": "SomeFramework.framework/SomeFramework"
        }
      }
    },
    {
      "engine": "XcodeUnitTestEngine",
      "unit.engine.xcode.config": {
        "build": {
          "workspace": "YourWorkSpace.xcworkspace",
          "scheme": "AnotherScheme",
          "configuration": "Debug"
        }
      }
    }
  ]
}

Viewing coverage results in Phabricator

Coverage will appear for affected source files in Side-by-Side mode as a colored bar.

License

Licensed under the Apache 2.0 license. See LICENSE for details.

About

An Xcode test engine for use with Phabricator's arc command line tool.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages